- Code: Select all
char *key = GetKeyState();
if(state == 0 || state == 1)
{
if(key[KEY_RIGHT]==1&&key[KEY_LEFT]==0&&xvelocity < 3.5)xvelocity += .7;
if(key[KEY_RIGHT]==0&&key[KEY_LEFT]==1&&xvelocity > -3.5)xvelocity -= .7;
}
then on collision with the top of ground
- Code: Select all
if(xvelocity < 0)xvelocity += .35;
if(xvelocity > 0)xvelocity -= .35;
when i let go of left the player doesn't stop sliding.
The player does stop sliding on wichever one is on top for the second code, i even tried adding another else and if event to see if it was just a script editor glitch, but it doesn't work! I want the player to slide when he lets go of the keys, but he should stop, right? Is there something wrong with my code? Or is there a better way of doing this?
Thanx, i hate to sound mad but i've been working on this for ever