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

Galaxy Ghosts

Embark on an exciting journey to create your own space-themed game, 'Galaxy Ghosts', using MakeCode Arcade. Learn to create and control player and enemy sprites, program interactions, and add a scoring system. By the end, you'll have a fully functional game where you can shoot at enemy sprites and earn points. Ready to start your coding adventure?
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 Galaxy Ghosts

    Welcome to the Galaxy Ghosts lesson! In this lesson, we will be using MakeCode Arcade to create an exciting space-themed game. You will learn how to create and control a player sprite, generate enemy sprites, and program interactions between them. By the end of this lesson, you will have a fully functional game where your player sprite can shoot at the enemy sprites and earn points. Let's get started!


    2 - Start a New Project

    Open the MakeCode Arcade website using the link below and create a new project. You can call the project whatever you want.

    https://arcade.makecode.com

    3 - Create your player

    First let's create our player sprite.

    Add the following code and choose the blue space ship sprite:

    let mySprite: Sprite = null
    mySprite = sprites.create(img`
        . . . . . . . c d . . . . . . . 
        . . . . . . . c d . . . . . . . 
        . . . . . . . c d . . . . . . . 
        . . . . . . . c b . . . . . . . 
        . . . . . . . f f . . . . . . . 
        . . . . . . . c 6 . . . . . . . 
        . . . . . . . f f . . . . . . . 
        . . . . . . . 8 6 . . . . . . . 
        . . . . . . 8 8 9 8 . . . . . . 
        . . . . . . 8 6 9 8 . . . . . . 
        . . . . . c c c 8 8 8 . . . . . 
        . . . . 8 8 6 6 6 9 8 8 . . . . 
        . . 8 f f f c c e e f f 8 8 . . 
        . 8 8 8 8 8 8 6 6 6 6 9 6 8 8 . 
        8 8 8 8 8 8 8 8 6 6 6 9 6 6 8 8 
        8 8 8 8 8 8 8 8 6 6 6 6 9 6 8 8 
        `, SpriteKind.Player)
    

    4 - Move left and right

    We want to position the player sprite at the bottom of the screen and use the joystick (or arrow keys on your keyboard) to move it left and right.

    Add the following new code:

    let mySprite: Sprite = null
    mySprite = sprites.create(img`
        . . . . . . . c d . . . . . . . 
        . . . . . . . c d . . . . . . . 
        . . . . . . . c d . . . . . . . 
        . . . . . . . c b . . . . . . . 
        . . . . . . . f f . . . . . . . 
        . . . . . . . c 6 . . . . . . . 
        . . . . . . . f f . . . . . . . 
        . . . . . . . 8 6 . . . . . . . 
        . . . . . . 8 8 9 8 . . . . . . 
        . . . . . . 8 6 9 8 . . . . . . 
        . . . . . c c c 8 8 8 . . . . . 
        . . . . 8 8 6 6 6 9 8 8 . . . . 
        . . 8 f f f c c e e f f 8 8 . . 
        . 8 8 8 8 8 8 6 6 6 6 9 6 8 8 . 
        8 8 8 8 8 8 8 8 6 6 6 9 6 6 8 8 
        8 8 8 8 8 8 8 8 6 6 6 6 9 6 8 8 
        `, SpriteKind.Player)
    mySprite.y = 110
    controller.moveSprite(mySprite, 100, 0)
    
    Make sure you select y in the position block and put in a value of 110. This will make the sprite go to the bottom.

    Click the + on the move block and have values of vx 100 and vy 0. This means we can move the sprite left and right (vx) but not up and down (vy).
    Once you've added the code check to see that your space ship is at the bottom and you can move it left and right.


    5 - Create the targets

    Now we will create the target sprites that we will shoot at. We will create a new target (enemy) sprite every 2 seconds.

    Add the following code and choose a sprite from the gallery. In this example we chose a ghost:

    let mySprite2: Sprite = null
    game.onUpdateInterval(1000, function () {
        mySprite2 = sprites.create(img`
            ........................
            ........................
            ........................
            ........................
            ..........ffff..........
            ........ff1111ff........
            .......fb111111bf.......
            .......f11111111f.......
            ......fd11111111df......
            ......fd11111111df......
            ......fddd1111dddf......
            ......fbdbfddfbdbf......
            ......fcdcf11fcdcf......
            .......fb111111bf.......
            ......fffcdb1bdffff.....
            ....fc111cbfbfc111cf....
            ....f1b1b1ffff1b1b1f....
            ....fbfbffffffbfbfbf....
            .........ffffff.........
            ...........fff..........
            ........................
            ........................
            ........................
            ........................
            `, SpriteKind.Enemy)
    })
    
    Make sure you select Enemy as the type for your target sprite.
    Once you've added the code you should see your target sprite in the middle of the screen. A new enemy sprite is being created every 2 seconds but as they're getting created on top of each other, you can only see one.

    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