How to Make a Person Walk in Game Maker 7
Game Maker 7 is a program released by YoYo Games that helps aspiring game developers ease into the art of game programing with a simple graphical interface for creating games. In Game Maker 7 you can create an animated sprite of a walking person and implement the event code for allowing that sprite to stop and start walking based on user input.
Things You'll Need
- Windows OS
- Game Maker 7
Use the resource menu to make a new sprite. Edit the sprite in the Image Editor to draw a picture of a man standing straight up in profile and save it by clicking the green check mark. Once you are back in the Sprite Editor, click "Animation" and "set length." You should enter the number of frames that your walk cycle will include as the length of the animation. For this tutorial, you will make the simplest walk cycle possible: enter an animation length of two. You should now see two thumbnails of your standing sprite. Open the second one, set the right mouse button to your background color, and use the draw box tool to erase the legs. Draw the legs now so that it appears that the man is walking, with one forward and the other back. Click the green check mark to save. Finally, create a sprite of a solid color to represent the floor. Be sure to turn off transparency for the floor sprite.
Use the resource menu to create an object that uses the floor sprite. Ensure that it is marked as visible and solid, and save it. Create a new room (again with the resource menu), and draw a simple floor along the bottom using your floor object and save.
Create the walkingMan object. Be sure to set the walkingMan object as being both solid and visible.
Add a "press spacebar" event. This event will use two actions. First, the "move fixed action," set to a speed of 1, a direction of right, and with the relative box checked. Second, find the "execute code" action under the Control tab and drag it into the "press spacebar" event's action list. A small text editor will pop up, and you should type in the following code: // Set the animation speed to 1. image_speed = 1
Add a "release spacebar" event. This event will also contain the same two actions, with a few changes. The fixed movement action in this event, rather than setting the speed to 1, will set it to 0, causing the man to stop moving. If you click "run" at this point, then you will get an animation of a man who walks forward whenever you press the spacebar and stops to walk in place whenever you release it. That's probably not what you want. You probably want your man to stand still when he is not walking forward, so you will write another "execute code" action to achieve this. This time, type in the following:// Set the animation speed to 0image_speed = 0// Set the animation frame to 0, so that our man is certain to be standing and not halfway through a stepimage_index = 0
Add the walkingMan object to the room and click "play."