Level 4 and Beyond - Monsters and Other Challenges

The game as it stands now starts looking nice, but is still completely trivial, and hence boring to play. So we need to add some action in the form of monsters. Also we will add some bombs and movable blocks and holes.

Next Level - Monsters

Create three different monsters: one that moves left and right, one that moves up and down, and one that moves in four directions. Adding a monster is actually very simple. It is an object that starts moving and changes its direction whenever it hits a wall. When the person hits a monster, it is killed, the level is restarted and the player looses a life. Give the person three lives to start with.

Let us first create the monster that moves left and right. When a collision occurs it reverses its horizontal direction.

The second monster works exactly the same way but this time we start moving either up or down and, when we hit a wall, we reverse the vertical direction.

The third monster is slightly more complicated. It starts moving either in a horizontal or in a vertical direction. When it hits a wall it looks whether it can make a left or a right turn. If both fail it reverses its direction. This looks as follows:

If you want to make the direction random try using chance.

To avoid problems with monsters being slightly too small, we uncheck precise collision checking and modify the mask to set the bounding box to the full image.

When the person collides with a monster, we have to make some awful sound, sleep a while, decrease the number of lives by one, and then restart the room. (Note that this order is crucial. Once we restart the room, the further actions are no longer executed.) The controller object, in the "no more lives" event, shows the high-score list, and restarts the game.

Lives

Give the player three lives.  It might though be nice to also show the number of lives. The controller object can do this in the same way as with the score. But it is nicer if you actually see small images of the person as lives. There is an action for this in the score tab. The drawing event now looks as follows:

 

Next Level - Bombs

Create a maze that is closed and add bombs and triggers to blow them up. The idea is that when the player gets to the trigger, all bombs explode, destroying everything in their neighborhood. This can be used to create holes in walls and to destroy monsters.

 

We will need three new objects: a trigger, a bomb, and an explosion.

The bomb is extremely simple. It just sits there and does nothing. To make sure monsters move over it (rather than under it) we set its depth to 10. Object instances are drawn in order of depth. The ones with the highest depth are drawn first. So they will lie behind instances with a smaller depth. By setting the depth of the bomb to 10 the other objects, that have a default depth of 0, are drawn on top of it.

The trigger is also rather simple. When it collides with the person it turns all bombs into explosions. This can be achieved by using the action to change an object in another object. At the top we indicate that it should apply to all bombs.

 

 

Explosion Strip

Explosion Sprite

Create an explosion object to show the animation. After the animation it destroys itself. (You have to be careful that the origin of the explosion is at the right place when turning a bomb into it.) The object also must destroy everything it touches. This requires a little bit of work. First of all, we do not want the explosion to destroy itself so we move it temporarily out of the way. Then we use actions to destroy all instances at positions around the old position of explosion. Finally we place the explosion back at the original place.

Destroy surronding objects

Note that this goes wrong if the person is next to the bomb! So make sure the triggers are not next to the bombs. It is important to carefully design the levels with the bombs and triggers, such that they present interesting challenges.

 

Next Level - Blocks and holes

 

Let us create something else that will enable us to make more complicated puzzles. We create blocks that can be pushed by the player.

 

Also we make holes that the player cannot cross but that can be filled with the blocks to create new passages.

 

This allows for many possibilities. Blocks have to be pushed in a particular way to create passages. And you can catch monsters using the blocks.

The block is a solid object. This main problem is that it has to follow the movement of the person when it is pushed. When it collides with the person we take the following actions: We test whether relative position 8*other.hspeed, 8*other.vspeed is empty. This is the position the block would be pushed to. If it is empty we move the block there. We do the same when there is a hole object at that position. To avoid monsters running over blocks we make the corner wall the parent of the block. This does though introduce a slight problem. Because a collision event is defined between the person and the corner wall and not between the person and the block, that event is executed, stopping the person. This is not what we want. To solve this we put a dummy action (just a comment) in the collision event of the person with the block. Now this event is executed instead, which does not stop the person. (To be precise, the new collision event overrides the collision event of the parent. As indicated before, you can use this to give child objects slightly different behavior than their parents.

The hole is a solid object. When it collides with the block it destroys itself and the block. We also make the corner wall its parent to let it behave like a wall.

With the blocks and holes you can create many intriguing rooms. There is though a little problem. You can easily lock yourself up such that the room can no longer be solved. So we need to give the player the possibility to restart the level, at the cost of one life. To this end we use the key R for restart. In this keyboard event for the controller we simply subtract one from the lives and restart the room.

This finishes our third version of the maze game. It now has all the ingredients to make a lot of interesting levels.

 

Some Final Improvements

Let us now finalize our game. We definitely should improve the graphics. Also we need a lot more interesting levels. To do this we add some bonuses and add a few more features. The final game can be found in the file maze_4.gmk.

Better graphics

The graphics of our current game is rather poor. So let us do some work to improve it. The major thing we want to change is to make the person look in the direction he is going. The easiest way to achieve this is to use a new image that consists of 4 subimages, one for each direction, as follows:

Normally Game Maker cycles through these subimages. We can avoid this by setting the variable image_speed to 0. When we change the direction of the character, we can change the subimage shown by the action to change the sprite:

A similar thing we can do for all the monsters but here there are no explicit events where we change the direction. It is easier to add a test in the end step event to see in which direction the monster is moving and adapt the sprite based on that.

Bonuses

Let us add two bonuses: one to give you 100 points and the other to give you an extra life. They are both extremely simple. When they meet the person they play a sound, they destroy themselves, and they either add some points to the score or 1 to the number of lives. That is all.

One way streets

To make the levels more complicated, let us add one-way streets that can only be passed in one direction. Make four objects, each in the form of an arrow, pointing in the directions of motion. When the person is completely on it we should move it in the right direction. We do this in the step event of the person. We check whether the person is aligned to the grid in the right way and whether in meets the particular arrow. If so, we set the motion in the right direction.

Now let’s make a game out of it

We now have created a lot of object, but we still don’t have a real game. A very important issue in games is the design of the levels. They should go from easy to hard. In the beginning only a few objects should be used. Later on more objects should appear. Make sure to keep some surprises that only pop up in level 50 or so. Clearly the levels should be adapted to the intended players. For children you definitely need other puzzles than for adults.

Also a game needs documentation. In Game Maker you can easily add documentation using the Game Information. Finally, players won’t play the game in one go. So you need to add a mechanism to load and save games. Fortunately, this is very easy. Game Maker has a built-in load and save mechanism. F5 saves the current game, while F6 loads the last saved game. You should though put this in the documentation.

You find a more complete game, including all this in the file maze_4.gmk. Please load it, play it, check it out, and change it as much as you like. In particular, you should add many more levels (there are only 20 at the moment). Also you can add some other objects, like e.g. keys that open certain doors, transporters that move you from one place in the maze to another, bullets that the person can shoot to kill monsters, doors that open and close from time to time, ice on which the person keeps moving in the same directions, shooting traps, etc.