Scratch Game
60 mins
+120 XP
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Maze Game

In this game students program their character to navigate their way through a maze using the arrow keys on their keyboard.

Teacher Notes Lesson Files

Live Class Feed

This is a live feed of the latest activity by your students on this lesson. It will update in real-time as they work on the lesson.
Load previous activity

    1 - Create a new Scratch project

    Create a new Scratch project and delete the cat.

    2 - Upload and add the maze sprite

    Save the maze picture in this step to your computer and upload it into Scratch as a new sprite. Once it appears, drag it into the center of the stage area.



    3 - Add the beetle sprite

    Add the 'Beetle' sprite from the sprite library.

    Drag the beetle to the start of the maze (the gap at the left of the maze).



    4 - Shrink the beetle

    As the beetle sprite is too big to fit through the corridors of our maze, we'll need to shrink it down. We also want to position the beetle at the start of the maze when we start the game, so we'll use a 'go to x [] y []' block to do this. Add the following code to the beetle:

    whenclickedsetsizeto15%gotox0y0set these so the beetle appears at the start of the maze

    The values for x and y will already be filled in for where your beetle is (at the start of the maze) so there's no need to change them.

    5 - Program the arrow keys to move the beetle

    Next we'll program the up, down, left and right arrow keys on your keyboard to move the beetle. Each of these keys will point the beetle in the appropriate direction and make it move 10 steps.

    We're going to program the up arrow first and then duplicate and change this code for the down, left and right keys.

    whenup arrowkeypressedpointindirection0move10stepswhendown arrowkeypressedpointindirection180move10stepswhenleft arrowkeypressedpointindirection-90move10stepswhenright arrowkeypressedpointindirection90move10steps

    ArrowDirection
    up0
    down180
    left-90
    right90

    Once you have all of the arrow keys programmed, click the green flag and then test each arrow key to see if it moves the beetle in the right direction. If any of them are not working, check the code for that arrow to make sure it's correct.


    Unlock the Full Learning Experience

    Get ready to embark on an incredible learning journey! Get access to this lesson and hundreds more in our Digital Skills Curriculum.

    Copyright Notice
    This lesson is copyright of Coding Ireland. Unauthorised use, copying or distribution is not allowed.

    Scratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab. It is available for free at https://scratch.mit.edu
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more