Makecode Arcade
Beginner
40 mins
Teacher/Student led
+140 XP

Studio: Donut Rush

Students build Donut Rush in MakeCode Arcade, a collection game with score and a countdown timer, then swap with a friend to compare one strength and one improvement in each design.

Teacher Class Feed

Load previous activity

    1 - Start: What We're Building ~4 mins

    Illustration for Start: what we're buildingToday you are coding in MakeCode Arcade. You will build Donut Rush step by step at your device: a collection game with score and a countdown.

    You can already work with sprites and simple events. Today you will put that together into a full timed game, then try a friend's version and compare design choices.

    Before anyone runs anything: what do you think will happen when the player overlaps a donut, and what should happen when the countdown runs out?

    2 - Introduction to Donut Rush ~2 mins

    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!


    3 - Creating a New Project ~3 mins

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

    4 - Setting up the Game ~6 mins

    This studio shows code two ways. Most steps give the code as text, and a couple show it as a picture of the blocks. They are the same program. At the top of the MakeCode Arcade editor there is a toggle that says Blocks | JavaScript, and you can move between the two whenever you like. To type the text below, switch to JavaScript.

    It is the same program either way. Flip back to Blocks whenever you like and you will see the code you typed as blocks, which is a good way to check you have it right. If a line will not go in, check the brackets and the capital letters, text is fussier than blocks.

    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.

    5 - Creating the Start Level Function ~2 mins

    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 () {
        
    }
    

    123learn · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. 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