A Mazing Game

maze.JPG


This lesson will cover
  • Game creation
  • Collision detection

Introduction
You are going to create a simple game where the player guides an “explorer” character around a maze using the arrow keys.
The game will end when the explorer rescues its friend in the middle.

Your teacher will now show you how this is completed.



Task 1: Setting the scene
Set up the game by importing the stage costume (Maze) and two sprites – an explorer and a friend for the explorer to rescue. Don’t do any more at this point.

Your background

Maze.gif
The Importance of Design

Before we make anything – a house, a dress or a computer program – we should start with a design. Because there are two important parts to most programs – the interface (how it looks) and the code – we design these separately.
● The easiest way to design the interface is by sketching it out on paper.
● To design the code, write out a list of steps it will have to perform in English. This is known as an algorithm and is just like the steps in a food recipe. Solving problems like this is what programming is really about, rather than entering commands on the computer.

All good programmers design algorithms before starting to code!



Task 2: Designing the solution

Let’s look again at the two main things we need to code in our game:
1. moving the explorer
2. reaching centre of the maze (and rescuing the explorer’s friend)

Open up the document below to find out more about your task:





Extension 1
Add a background tune to your game (sound “xylo1” seems to suit, but

choose what you think sounds best).
Think about the following:
  • Where would be the best place to store this, since it applies to the whole game?
  • How will you get the music to keep playing?
  • Should you use a play sound or play sound until done block to play the music?



Extension 2: Add an enemy
Add a sprite that constantly moves back and forth across the stage.
dragon.JPG
If your explorer touches the enemy, the explorer should go back to the start.
Hint: set your enemy sprite to move only left & right.

The if on edge, bounceblock is useful to bounce back and forth

off the edge of the stage.

position.JPG


Did you understand?

Complete the worksheet below: