- Code: Select all
switch(Dir)
{
case 0:
xv*=0.99; // this is the part that should make it decelerate
break;
case 1:
if(xv < MaxSpeed)//If sonic is not going as fast as he can...
{
xv += IncrementSpeed;//...then speed him up.
//You can also put animation code here ;)
}
break;
case -1:
if(xv > -MaxSpeed)
{
xv -= IncrementSpeed;//This will also speed him up. But in the opposite direction :D
//Again, you can put animation code here
}
break;
}
x+=xv;
You need to have an xv variable.
The thing I mentioned was that you probably have a left or right side collision with the new tile (the one that causes the stop) that stops the actor. If you remove that, then you wouldn't need the above fix.