Wikijunior:Raspberry Pi/Scratch Game – Simple Maze

Tutorial by Andrew Oakley
Public Domain
Updated Nov 2017
www.cotswoldjam.org

Getting started

edit
 
Select Scratch from the Programming menu in Raspberry Pi OS.

1. Click on the Raspberry menu, Programming, Scratch.

2. Click the Maximise Window button.
 

3. Select File menu, Open.
 

4. Click the Pi button.
 

5. Select Scratch and click OK.
 

6. Select simple-maze and click OK.

7. Select smaze1 and click OK. A green and blue maze should appear.
 

 

 

 

You should now be able to move the Smiley left and right, using the left and right arrow keys.

X is a "variable". A variable can hold a number or a word which can change. X measures the left and right positions.

 

You should now be able to move the Smiley up and down, using the up and down arrow keys. The Y variable measures up and down position.

The Smiley can now move anywhere around the maze, including through the walls.

We need to add rules

edit
  • To make the Smiley go back to the start if it hits a blue wall
  • To say "You win!" if the Smiley reaches the white outline of the exit

Create this new block

  

To select a colour

edit

1. Click the colour box.
 

2. Click the colour you need.
 

To start a new game

edit

Click the green flag.
 

What if you make a mistake?

edit

Right-click any block and click "delete".
 

For teachers / Scout / Guide leaders

edit

Downloads available from http://www.cotswoldjam.org/downloads/beavers

To add the files to Raspbian, go to the Terminal:  

cd
mkdir -p Scratch/simple-maze
cd Scratch/simple-maze
curl "http://www.cotswoldjam.org/downloads/beavers/cjam-scratch-simple-maze-code.zip" -O
unzip cjam-scratch-simple-maze-code.zip
exit

Note that -O is the capital letter O, not zero.

Files

edit

cjam-scratch-simple-maze.pdf

edit

The original PDF for this tutorial is on Wikimedia Commons: cjam-scratch-simple-maze.pdf

Maze-person.png

edit

 

Maze-stage.png

edit