This maze game has been adapted for school use from a lecture written by Carl Gustafsson.
In this activity we will create a maze game.
In a maze game the player should move around a grid based maze trying to find a certain point called the target. On the way around there are obstacles to overcome or things, such as diamonds, to collect.
|
|
The game will be built on an invisible grid made up of blocks that are 32
pixels wide x 32 pixels high. This makes the game easier to design and
reduces the chance of the player getting 'stuck' anywhere.
Add 2 rooms. Set the room size to be 480x480 pixels and set the grid to be 32x32 pixels.
|
|||||||||
|
|
Start off by adding 3 sprites: a wall, a person and a target. Choose the wall sprite from the Pacman folder, because it is 32x32 pixels in size. The target sprite is called special.gif and is also in the Pacman folder. For your person, choose any suitable sprite, such as the ghost from the various folder. Name them sprWall
For the sprWall, make sure transparent is not ticked. (otherwise it won't look very good - it is square and no part of it should be transparent) |
|||||||||
|
|
Now create a wall object:
Create the person object
Create a target object
|
|||||||||
|
|
Set up movement for the personThe person will move from point to point on the grid as the cursor keys are pressed.
Add an event to the person object for the Keyboard <Left>
Add actions for the up, down and right keys. (You can use the duplicate event option to make this job easier) Your actions should look like this for each key.
|
|||||||||
|
|
Set up collision handlingIf the person collides with a wall it should stop, so add a collision event. In the actions just stop the person moving. You don't need to check for grid alignment first; just add a snap to grid action afterwards so that the person is still aligned on the grid. This is what you will need for the person object:
|
|||||||||
|
|
Add a collision event to the target object for a collision with objPerson We want to test whether the next room exists (we could be in the last room) before we move on to it. So if the next room exists we will move into it, otherwise we must be in the last room so we will end the game. These are the actions you will need:
|
|||||||||
Draw 2 maze-like rooms, making sure that you have walls
all around the outside. Place the person and target at the beginning and
end of your maze.
|
||||||||||
|
You should now have a very simple maze game with two levels! To make your game even more exciting than this, move on to Maze Game 2 |




Add the action from
the Control tab 'If instance is aligned with grid'





