GAME MAKER STUDIO TUTORIAL

THE CLOWN GAME

GAME MAKER STUDIO 1.4

separator-blank.png

GameMaker Version 1.4.1749

 

1 – Create a clown sprite

·       Name: spr_clown

·       Load image file from Resources folder

2 – Create a wall sprite

·       Name: spr_wall

·       Load file from Resources folder

3 – Create a bounce sound

·       Name: snd_bounce

·       Load file from Resources folder

4 – Create click sound

·       Name: snd_click

·       Load file from Resources folder

5 – Create the clown object

·       Name: obj_clown

·       Select sprite: spr_clown

6 – Create the wall object

·       Name: obj_wall

·       Select sprite: spr_wall

·       Check “solid” property

7 – Making the clown object move

·       Inside clown, add a Create event

·       Add a Fixed Motion action (move tab)

o   All directions but middle

o   Speed: 4

8 – Handling collisions

·       Inside the clown object, add a Collision event (obj_wall)

·       Add a Bounce action (move tab)

·       Add a Play Sound action (main1 tab)

o   Sound: snd_bounce

9 – Create a room

·       Under Settings tab, name: rm_main

·       If necessary, under Object tab, enlarge window and set snapX and snapY to 32

o   This is to match the size of our sprites.

·       Under the Object tab, with the clown object selected (on the left), click in room to add one clown instance to it.

·       Switch to wall object and add walls all around the room.

·       If you wish, you can also resize the room so that you have a smaller area to work with.

Save your game.  Test it.

You should have a clown that bounces around in your room.

 

 

10 – Randomizing the clown's starting direction

·       Go inside the Create event of the clown object.

·       Insert an Execute Code action (control tab)

·       Insert the following code:

          randomize();

·       Make sure the Execute Code action is above the Move Fixed action.  You can drag it above.

Save your game.  Test it.

Your clown should now start in different directions each time that you test your game.

 

11 – Handling when a clown is clicked on

·       Inside the clown object, add a Mouse event (Left Pressed)

·       Add a Play Sound action (main1 tab)

o   Sound: snd_click

·       Add a Jump To Random action (move tab)

o   Do not change anything

·       Add a Moved Fixed action (move tab)

o   Choose all directions but the STOP in the middle

o   For speed, set it to 0.5, relative (In other words, increase speed by 0.5)

Save your game.  Test it.

Your clown should now react when it is clicked. 

 

Please turn down your volume.

 

12 – Adding background music

·       Resources>Create Sound

o   Name: snd_music

o   Load file music.mp3 from resources

·       Inside clown object, inside create event, add Play Sound action with above sound. 

o   Sound: snd_music

o   Loop: true

13 – Adding a background image

·       Resources > Create background

o   Name: bg_main

o   Load file background.png from resources

·       Inside our room object, click on background tab.

o   Uncheck Draw Background Color box

o   Set background to back_main (see icon about midway down)

Save your game.  Test it.

You should now have background music and a background image.

 

Please turn off your volume so that further testing will not be disruptive.

 

14 – Making the clown change directions from time to time

·       Go inside create event of the clown object and add Set Alarm (main2 tab)

o   Number of steps: 60

o   Alarm number: Alarm 0

·       In the clown object, add a new Alarm event (Alarm 0)

·       Inside that event, add the moved fixed action (like before) with speed 0, relative

o   All directions by middle

o   Speed: 0

o   Check relative

·       Still inside the same event, add once again the Set Alarm action (main2 tab)

o   Number of steps: 60

o   Alarm number: Alarm 0

Save your game.  Test it.

Your clown should now change directions every two seconds.

 

15 – Adding a score

·       Create a new object

o   Name: obj_controller

o   No sprite

·       Inside this new object, add a Draw > Draw GUI event

·       Inside the Draw GUI event, insert a Draw Score action (score tab)

o   X: 32

o   Y: 32

·       Go to the room object, in the Object tab and add an obj_controller to the room.

·       Go to the clown object, in the Left Pressed event, add a Set Score action (score tab).

o   New score: 10

o   Check relative

Save your game.  Test it.

Your score should go up by 10 every time you click on the clown.

GOT EXTRA TIME?

·       Use the clowEvil.png sprite in the resources to create an object that is identical to our existing clown but removes from your score when you click it.

·       Make the evil clown object bounce when it hits the normal clown.

·       Add several of each clown to make it more likely that the player clicks on the evil clown.

·       Create a fake wall object with the wallFake.png image in the resource folder. This wall does nothing and clowns bounces through it.  This adds another little way to confuse the user.

SOURCE

separator-campeau.png