Game Microbit
Advanced
60 mins
Teacher/Student led
+115 XP
What you need:
Chromebook/Laptop/PC
Microbit

Microbit - Invaders

Follow this guide to build an exciting game on your Microbit. Start by creating a project, set up a countdown timer, design player and enemy sprites, and code movements and interactions to score points or end the game.
Learning Goals Learning Outcomes Teacher Notes

Teacher Class Feed

Load previous activity

    1 - Creating a Microbit Project

    We have to make a microbit project first. 

    To do this, we can go to the microbit website https://makecode.microbit.org/. . Then, we can click New Project to start making our Microbit project.

    2 - Creating a Countdown Timer

    For this part, we are going to create a countdown timer that starts from 3. 

    To add the countdown timer, we can follow the code below. This code will be using the show number and pause blocks that were in the Basic category.

    basic.showNumber(3)
    basic.pause(1000)
    basic.showNumber(2)
    basic.pause(1000)
    basic.showNumber(1)
    basic.pause(1000)

    3 - Creating the Player, Enemy and Bullet Variables

    For this project, we are going to create three variables; Bullets, Players and Enemy.

    To create our variables, we can click on the Variables category and press the Make a Variable button. We can name these variables Bullets, Players and Enemy.

    4 - Creating the Player Sprite

    Now, we are going to create our player sprite and the enemy sprite. 

    For our player sprite, it will be on the left side of the screen. We can use the code below to do this.

    let Player: game.LedSprite = null
    Player = game.createSprite(2, 4)


    5 - Moving the Player Sprite

    For this part, we are going to be moving our player sprite using the A and B buttons. The A button will move our player sprite to the left while the B button will move it to the right. 

    The code below will handle this logic.

    input.onButtonPressed(Button.A, function () {
    let Player: game.LedSprite = null
        Player.change(LedSpriteProperty.X, -1)
    })
    
    input.onButtonPressed(Button.B, function () {
    let Player: game.LedSprite = null
        Player.change(LedSpriteProperty.X, 1)
    })
    

    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 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