Scratch Game
Beginner
60 mins
Teacher/Student led
105 points
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Maze Game

This lesson guides students through creating a Maze Game using Scratch. They'll learn to program a character to navigate a maze, modify sprite size and position, and code keyboard controls. The lesson also includes instructions on how to prevent the character from passing through maze walls.
Learning Goals Learning Outcomes 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 - Introduction to Maze Game

    Welcome to our exciting Maze Game lesson! In this lesson, you will learn how to program a character to navigate through a maze using the arrow keys on your keyboard. You will be using Scratch, a fun and easy-to-use coding platform. By the end of this lesson, you will have created your very own maze game. Let's get started!


    2 - Open the starter project

    Open the following Scratch starter project that already has a maze sprite added to it.

    Open Starter Project

    3 - Add the Beetle sprite

    Add the Beetle sprite from the sprite library.

    The beetle will be the character that we will code to move through 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:

    when green flag clicked set size to (15) % go to x [-160] y [-75] // the start of the maze

    Once you've added the code, click on the green flag and the beetle should shrink and go to the start of the maze.


    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.

    ArrowDirection
    up0
    down180
    left-90
    right90
    when [up arrow v] key pressed point in direction (0) move (10) steps when [down arrow v] key pressed point in direction (180) move (10) steps when [left arrow v] key pressed point in direction (-90) move (10) steps when [right arrow v] key pressed point in direction (90) move (10) steps
    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