Maze Level 2 - Collecting Objects
Design an animated
Door Sprite and name it spr_door.
Design a sprite
for a collectable object. It should be animated. It could be a diamond or
walls if you choose.
The goal of this level is to collect objects (i.e. diamonds)
. The collecting itself is easy. But
how do we make sure the player cannot exit the room until all diamonds are
collected? Create a door object that will behave like a wall as long as there
are still diamonds left, and will disappear (or change images) when all diamonds
The diamond is an extremely simple object. The only
action it needs is that it is destroyed when the person collides with
it. So in the collision event we put an action to delete it.
The door object will be placed at a crucial place
to block the passage to the goal. It will be solid (to block the person
from passing it). In the collision event of the person with the door
we must stop the motion. In the step event of the door we check whether
the number of diamonds is 0 and, if so, destroys itself. There is
an action for this. We will also play some sound such that the player
will hear that the door is opened. So the step event looks as follows:
Note that the score is automatically displayed in the caption. This is
though a bit ugly. Instead we will create a controller object. It
does not need a sprite. This object will be placed in all rooms. It
does some global control of what is happening. For the moment we just
use it to display the score. In its drawing event we set the font
and color and then use the action to draw the score.
Put this object in every level
must create the font
Finishing the Level
Finishing the level gives 40 points so we add 40 points to the score in
the collision event for the goal with the person.
A game without sounds is pretty boring. So we need some sounds. First
of all we need background music. For this use some nice midi file.
Start this piece of music in an object without a sprite (obj_music),
looping it forever. Next we need some sound effects for picking up
a diamond, for the door to open, and for reaching the goal. These
sounds are called in the appropriate events described above. When
reaching the goal, after the goal sound, it is a good idea to put
a little sleep action to have a bit of a delay before going to the