Create a maze game with levels
Lauch GameMaker, create a new project, and you're good to go.
1. Sprites
Below you'll see three sprites that we're going to use in the maze game (save them). The goal of the game is to get Mr. skeleton to eat an apple, but before he can enjoy the delicious apple, he has to through a maze. You can also draw your own sprites.
Head back to GameMaker and click the red pacman icon. This will create a sprite.
Give it a nice name, you now have two choices:
1 Load a sprite (if you have an image file you want to use)
2 Draw your own sprite.
Give it a nice name, you now have two choices:
1 Load a sprite (if you have an image file you want to use)
2 Draw your own sprite.
Do this with the other two sprites (the wall and the apple) as well. When you're done it should look like this:
2. Objects
A sprite alone can't do anything. It is just an image. To make it do things, we need to create an object, give it a name, and link the sprite. It is the objects that does all the fancy work. Let's start with Mr. Spook.
We want Mr. Spook to move when we press the arrow keys. We also want the game to go to the next level when Mr. Spook eats the apple.
First, we will make him move. We need to add an event. An event tells the object when to do different things. For example when the player presses the right arrow key. In this case, we want Mr. Spook to move when we press the arrow keys. Start by adding a Keyboard Event with the key <Right>.
First, we will make him move. We need to add an event. An event tells the object when to do different things. For example when the player presses the right arrow key. In this case, we want Mr. Spook to move when we press the arrow keys. Start by adding a Keyboard Event with the key <Right>.
On the right side of the object inspector window, you will see some small buttons. All of those buttons will make your object do something. If you drag them (or right click them), they will be used in the event that is currently selected.
The one we're going to use is the "Jump to position" function. You can see it below. Drag it (or right-click it), and a menu will pop up.
The one we're going to use is the "Jump to position" function. You can see it below. Drag it (or right-click it), and a menu will pop up.
This will move the player 4 pixels forward on the x-axis. That means that the player will move to the right. Play around with the values and see what fits you. 4 is a good number tho.
Now the player can move to the right, hurray. But when Mr. Spook walks into a wall, he will just spook right through it, and since spooking is illegal that is not going to happen. Therefore we need to check if the place is free at the position where Mr. Spook is moving to. To do that, drag (or right click) this:
Now the player can move to the right, hurray. But when Mr. Spook walks into a wall, he will just spook right through it, and since spooking is illegal that is not going to happen. Therefore we need to check if the place is free at the position where Mr. Spook is moving to. To do that, drag (or right click) this:
Notice that we check the "Relative" button. That is because we want Mr. Spook to check if the place is free relative to his current position. If we did not check that, we would just check if the position in the room was free, and not where Mr. Spook is moving to. If you've done everything correct, you should have someting like this:
Note that we first check if the place is free, and then we move Mr Spook.
Right click the <Left> event and duplicate it to a <Right> event. Then make all the values negative. This will make the player move to the right.
Do the same with up and down, except that you use the y-axis to make the player move up and down.
Right click the <Left> event and duplicate it to a <Right> event. Then make all the values negative. This will make the player move to the right.
Do the same with up and down, except that you use the y-axis to make the player move up and down.
Now that we're done with Mr. Spook for now, let's make a wall. Create a new object, give it a name, link it to the wall sprite and make it solid.
That way the function that checks if a place is free knows that the wall is a solid object, therefore it will notice that there is a wall. If the wall was not solid, it would not notice anything, and Mr. Spook would just move through it.
That way the function that checks if a place is free knows that the wall is a solid object, therefore it will notice that there is a wall. If the wall was not solid, it would not notice anything, and Mr. Spook would just move through it.
3. Rooms
The objects are ready, and it is time to build a level. Levels are called rooms in gamemaker. Create a room and fill in some objects
You can select which object you're placing in the room in the objects tab. I've set the background color to black. You can set a background color in the backgrounds tab, and you can adjust the size of the room in the settings tab.
Run the game and see the magic you've just made.
4. Multiple levels
The game would be way too easy to complete if it only contained one level. Create a new object for the apple. Leave it the way it is, and open up the Mr. Spook object. Add a collision event. A collision event will fire when the object that has the event touches another specific object.
Place an apple in the first level, create a new room, place an apple in it, and so on If you have no inspiration here's a very hard level
Congratulations, you've made a maze game!
.. and if you're not, then you can just download the source code below and pretend to all your friends that you made it.
![]()
|
![]()
|