Game Arcade
Advanced
60 mins
Teacher/Student led
210 points
What you need:
Chromebook/Laptop/PC or iPad/Tablet

Donut Rush

Embark on an exciting journey to create your own interactive game, 'Donut Rush', using MakeCode Arcade. Learn to write code for game sprites, handle events like sprite overlaps, and control game logic. Create a new project, set up the game, create the start level function, set up the level, create the donuts, start the game, collect the donuts, complete the level, and finally, play your game!
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 Donut Rush

    Welcome to the 'Donut Rush' game creation lesson! In this exciting course, you'll learn how to create your very own interactive game using MakeCode Arcade. The game you'll be creating is called 'Donut Rush'. The goal of the game is to collect as many donuts as possible within a set time limit. You'll learn how to write code to create game sprites, handle events like sprite overlaps, and control the game logic. Let's get started!


    2 - Creating a new project

    Start by creating a new project in MakeCode Arcade. To do this, go to the MakeCode Arcade website and click on 'New Project'.

    3 - Setting up the Game

    Let's set up the game. We'll create a splash screen, set up some variables, and create our player sprite. The splash screen is the first screen that appears when the game starts. It's a great place to display the game's title or any instructions for the player.

    The variables we're creating will be used to keep track of the game's state:

    • The 'level' variable will keep track of the current level.
    • The 'target' will store the number of donuts to be collected in the current level.
    • The 'collected' will keep track of the number of donuts the player has collected so far.

    Add the following code:

    let mySprite: Sprite = null
    let collected = 0
    let target = 0
    let level = 0
    game.splash("Collect the donuts!")
    level = 1
    target = 0
    collected = 0
    mySprite = sprites.create(img`
        . . . . . . 5 . 5 . . . . . . . 
        . . . . . f 5 5 5 f f . . . . . 
        . . . . f 1 5 2 5 1 6 f . . . . 
        . . . f 1 6 6 6 6 6 1 6 f . . . 
        . . . f 6 6 f f f f 6 1 f . . . 
        . . . f 6 f f d d f f 6 f . . . 
        . . f 6 f d f d d f d f 6 f . . 
        . . f 6 f d 3 d d 3 d f 6 f . . 
        . . f 6 6 f d d d d f 6 6 f . . 
        . f 6 6 f 3 f f f f 3 f 6 6 f . 
        . . f f d 3 5 3 3 5 3 d f f . . 
        . . f d d f 3 5 5 3 f d d f . . 
        . . . f f 3 3 3 3 3 3 f f . . . 
        . . . f 3 3 5 3 3 5 3 3 f . . . 
        . . . f f f f f f f f f f . . . 
        . . . . . f f . . f f . . . . . 
        `, SpriteKind.Player)
    controller.moveSprite(mySprite, 70, 70)
    


    Set level to 1.

    Set target to 0.

    Set collected to 0.

    4 - Creating the Start Level Function

    A function in programming is a reusable piece of code. It allows you to group several commands together, which can then be called upon whenever you need them. This helps to make your code more organised and efficient.

    Create a function called startLevel

    function startLevel () {
        
    }
    

    5 - Set up the level

    Now let's add some code to the function. This code will run each time we want to setup and start a new level in the game.

    Here's what we will does:

    1. Set the variable 'collected' to 0. This variable keeps track of how many donuts the player has collected.
    2. Set the background colour of the game scene to a random colour.
    3. Display a message saying 'Level ' followed by the current level number.
    4. Set the target number of donuts to collect for the level (5 + the current level number).
    5. Start a countdown of 10 seconds for the level.

    Add the following code inside the startLevel function:

    let mySprite: Sprite = null
    
    function startLevel () {
        collected = 0
        scene.setBackgroundColor(randint(3, 7))
        mySprite.sayText("Level " + level, 1000, false)
        target = 5 + level
        info.startCountdown(10)
    }
    

    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 DigitalSkills.org. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more