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 something else.

Design additional 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 have gone.


The Objects

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:




For each diamond collected we earn 5 points. So in the destroy event of the diamond we add 5 points to the score. Finishing the level gives 40 points so we add 40 points to the score in the collision event for the goal with the person.

For now we will assume this is the last room ...... this will change later.

When the player reaches the last room a high-score table must be shown. This is easy in Game Maker because there is an action for this. The goal object does become a bit more complicated though. When it collides with the person the following event is executed:

It adds something to the score, plays a sound, waits a while and then either goes to the next room of, if this is the last room, shows a message, the high-score table, and restarts the game.

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.




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 next room.