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

Space Dodge

In this step-by-step lesson, students will learn how to create a thrilling 'Space Dodge' game using MakeCode Arcade. They will design a spaceship, control its movements, create asteroids, and set up game mechanics such as lives and collision effects. The lesson provides a fun and interactive way to learn coding concepts.
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 Space Dodge

    Welcome to the 'Space Dodge' lesson! In this lesson, you will learn how to create a fun and exciting game using MakeCode Arcade. You will control a spaceship and dodge asteroids that come flying at you. Let's start our space adventure!


    2 - Create a new Arcade project

    Go to the arcade.makecode.com website and create a new project.

    3 - Create your spaceship sprite

    In this game you will control a spaceship that has to dodge asteroids that come flying at it.

    Add the following code to create the spaceship sprite and use the sprite editor to design your spaceship. It should point towards the right as that's where the asteroids will be coming from.

    Rename your sprite to spaceship.
    let spaceship = sprites.create(img`
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . d d d . . . . . . . . 
        . . 2 2 2 1 1 1 d d . . . . . . 
        . . 2 4 4 1 1 1 1 1 d d . . . . 
        . 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        2 4 4 5 5 1 1 1 1 1 1 1 1 1 d d 
        2 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        . 2 2 4 4 1 1 1 1 d d d . . . . 
        . . 2 2 2 d d d d . . . . . . . 
        . . . . 2 d d . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        `, SpriteKind.Player)



    4 - Control the spaceship

    Now add the following new code to control the spaceship with the arrow keys and set it so that it cannot go off the screen.

    let spaceship = sprites.create(img`
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . d d d . . . . . . . . 
        . . 2 2 2 1 1 1 d d . . . . . . 
        . . 2 4 4 1 1 1 1 1 d d . . . . 
        . 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        2 4 4 5 5 1 1 1 1 1 1 1 1 1 d d 
        2 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        . 2 2 4 4 1 1 1 1 d d d . . . . 
        . . 2 2 2 d d d d . . . . . . . 
        . . . . 2 d d . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        `, SpriteKind.Player)
    controller.moveSprite(spaceship, 150, 150)
    spaceship.setStayInScreen(true)
    
    Make sure each block has the spaceship variable selected in it.

    Click on the + on the move with buttons block and put in vx 150 and vy 150 to set the velocities for the x axis and y axis.
    Once you've added the code test that you can move your spaceship around with the joystick (or the arrow keys on your keyboard).

    5 - Set the number of lives

    Now let's set the number of lives that the player will start with.

    Add the following new code:

    let spaceship = sprites.create(img`
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . d d d . . . . . . . . 
        . . 2 2 2 1 1 1 d d . . . . . . 
        . . 2 4 4 1 1 1 1 1 d d . . . . 
        . 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        2 4 4 5 5 1 1 1 1 1 1 1 1 1 d d 
        2 2 4 4 5 1 1 1 1 1 1 1 d d . . 
        . 2 2 4 4 1 1 1 1 d d d . . . . 
        . . 2 2 2 d d d d . . . . . . . 
        . . . . 2 d d . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        `, SpriteKind.Player)
    controller.moveSprite(spaceship, 150, 150)
    spaceship.setStayInScreen(true)
    info.setLife(3)
    
    Notice that there's 3 hearts on your screen that represent the number of lives.

    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