Hey guys, im new at this so i dont have a lot of experience but im developing a 2d game and i dont want to use the Game Maker movement controls, i want to make my own code for it, and i was doing it well until i noticed the player stops quickly and i want him to continue walking a few moments after i stop pressing the direction button, then i did this code here:
///Stop slowly
repeat(10)
{
while(walking_speed > 0)
{
while(walking_direction == 1)
{
x = x-walking_speed;
walking_speed -= 1;
if(walking_speed = 0)
{
walking_direction = 0;
}
}
while(walking_direction == 2)
{
x = x+walking_speed;
walking_speed -= 1;
if(walking_speed = 0)
{
walking_direction = 0;
}
}
}
}
Thats Game Maker code. Then, what it does is repeat that code 10 times (as the maximum walking_speed is 10, then it would be subtracting 1 to the walking_speed every time the code runs) and the code works, my problem is this one: The code runs the 10 times at the same time. I need it to run once every frame, and i actually dont have idea of how to do it.
This should be a really easy code, but i repeat, im new at this. Also i want to make a good game.
Thanks for reading.