Adding a Run button
One of my first "Aha!" moments in gaming as a kid was finding out that in Super Mario Bros, you could hold down the B button to make Mario run, allowing you to jump farther than a normal jump. Regardless of how you remember it, there was something exciting about moving that quickly, as though you were flying through this world by the seat of your pants. One false move and you were done for! Why not recreate that excitement by adding a run button of your own?
Getting ready
You'll need a character (obj_player
) who has movement controls, at least horizontally. Refer to the code in the previous section if you need it.
How to do it...
- Open
obj_player
. - Click on the Step event and open the
control movement
code block. - Below the movement code, add the following code:
//make the character run if keyboard_check(vk_shift) { hspeed = (hspeed*2); }
That's it!
How it works...
This piece of code is simple as it is short. All it tells GameMaker to do is to check whether...