GAME MAKER STUDIO TUTORIAL
THE CLOWN GAME
GAME MAKER STUDIO 2.2

1 – Create
a clown sprite
· Name:
spr_clown
· Import
image file from Resources folder
2 – Create
a wall sprite
· Name:
spr_wall
· Import
image file from Resources folder
3 – Create a
bounce sound
· Name:
snd_bounce
· Press
the … button to choose the file from Resources folder
· You
can press the Play button to test the sound.
4 – Create
click sound
· Name:
snd_click
· Press
the … button to choose the 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
7 – Making
the clown object move
· Inside
clown, add a Create event
· Add
a Set Direction Random action (Movement menu)
o Click
on all directions so that one will be chosen randomly
· Add
a Set Speed action (Movement menu)
o Speed:
4
8 –
Handling collisions
· Inside
the clown object, add a Collision event (obj_wall)
· To
make the clown bounce off the walls, we need to add an Execute Code action
(Common menu)
o Add
the following code:
move_bounce_all(false)
· Add
a Play Audio action (Audio menu)
o Sound:
snd_bounce
9 – Open
the default Room 0.
· On
the left (in the Layers panel), make sure that the Instances layer is
selected.
· Drag
in the wall objects to create a large rectangular room (see image below).
Note: Using the ALT key makes this
much faster. On the Mac, the right
ALT key will work.
· Drag
a clown into the room inside the walls.
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 (Common menu)
· Insert
the following code:
randomize();
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 Audio action (Audio menu)
o Sound:
snd_click
· Add
a Jump To Point action (Movement menu)
o
We want to jump to a random point with
(x,y) values in the
room. We can do this by setting x to
a random value between 0 and the room’s width and by setting y to a random
value between 0 and the room’s height.
The function called random(maxNumber) does
this for us.
Fill out the action exactly as shown below:

· Add
a Set Direction Random action (Movement menu)
o Choose
all directions.
· Add
a Set Speed action (Movement menu)
o Speed:
0.5
o Check
relative
Note: Checking relative means that
we will add 0.5 to the current speed every time the clown is clicked.
Save your game. Test it.
Your clown should now react when it is clicked.
Please turn down your
volume.
12 –
Creating the background music asset
· Create
a new Sound resource
o Name:
snd_music
o Load
file music.mp3 from resources
13 – Adding
the background music to the game
· Inside
clown object, inside create event, add Play Audio action (Audio menu)
o Sound:
snd_music
o Loop:
Check it!
14 –
Creating the background image asset
· Create a sprite resource
o Name: spr_background
o Load
file background.png from resources
15 – Adding
the background to your game
· Open
the room object.
· Make
sure that the Background Layer is selected in the Layers panel.
· Locate
the Background Layer Properties panel
o Using
the … button, select our background sprite.
o Horizontal
tile: Check it.
o Vertical
tile: Check it.
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.
· Add
a Set Alarm Countdown action (Instances menu)
o Alarm
number: 0
o Countdown:
120 (which
means 2 seconds)
· In
the clown object, add a new Alarm event (Alarm 0)
· Inside
that event, add a Set Direction Random action (Movement menu)
o Choose
all directions.
· Still
inside the same event, add once again the Set Alarm Countdown action
(Instances menu)
o Number
of steps: 120
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 Value action (score tab)
o Caption:
“Score:”
o Value:
score
o X:
0
o Y:
0

· Go
to the room object and add an obj_controller to
the room. It will show as a simple
little question mark in a circle.
· Go
to the clown object and inside the Left Pressed event.
· Add
a Assign Variable action (Common menu).
o Name:
score
o Value:
10
o Check
relative
Save your game. Test it.
Your score should go up by 10 every time you click on the clown.
|