Slowly make a ship stop

B

Bokkie2988

Guest
Hi,
I have a question about my code. Here it is:
Code:
if (keyboard_check(ord("W")))
{
    var flyspeedtemporary = 4;
    motion_set((image_angle + 90),flyspeedtemporary);
}
Now how do I make it that when the player stops holding W, the ship will slowly stop, and not abrupt?

Thanks,
Bokkie
 

Lazzeking

Member
Never used motion_set , but i will assume that is setting the speed variable , so i'd do something like this:
Code:
if (keyboard_check(ord("W")))
{
    var flyspeedtemporary = 4;
    motion_set((image_angle + 90),flyspeedtemporary);
}else{
    if (speed > 0)
        speed -= 0.5; //other valid alternatives are 0.1,0.2,0.4,0.8
}
EDIT: Gave the documentation a quick read and yeah, it sets a new speed...so this should work
 
Last edited:
Top