hey guys how can I increase speed on my character, okay at first the xvelocity=2; right? then I want it to pick up speed.
let me clearify that this is not my actor its my enemy on the screen which I want it to pick up speed.
#define MaxSpeed 5 //Max Speed
#define RIGHT 0
#define LEFT 0
double SPEED; //Max speed
void
Gain(int d) //d is direction
{
switch(d)
{
case 0: //Right
if(SPEED<MaxSpeed) // if speed is less than max speed
{
SPEED+=.25;
}
x+=SPEED;
break;
case 1: // Left
if(SPEED>(-MaxSpeed)) // If it's less than -maxspeed
{
SPEED-=.25;
}
x-=SPEED;
break;
}
}
Gain(0);
Gain(1);
#define maxspeed 10
float speed = 0.5;//You can replace 0.5 and 10 with any other numbers you like ;)
if(xvelocity < maxspeed)
{
xvelocity += abs(speed);
}
if(xvelocity < -maxspeed)
{
xvelocity -= abs(speed);
}
xvelocity = min(xvelocity+1,maxspeed)
Hblade wrote:Collisions will goof with that method though wont they?
Hblade wrote:Other than that, it's epicly short o-o
foleyjo wrote:raminkhan said this is for the enemy so I'm guessing it is not dependent on key presses and direction isn't a factor also.
foleyjo wrote:Create a repeating timer and in the OnTimer code putxvelocity = min(xvelocity+1,maxspeed)
Users browsing this forum: No registered users and 1 guest