Game Arcade Inventor Project
Normal
60 mins
260 points
What you need:
  • Computer/laptop
  • Arcade computer

Arcade Space Shooter

Control a space ship that has to dodge and shoot asteroids!

1 - Create a new Arcade project

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

2 - Create your spaceship sprite

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

Add the following code to create the spaceship sprite and use the sprite editor to design your spaceship.

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)

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

4 - Set the number of lives

Arcade is designed for programming games so there's lots of helpful blocks that we can use.

To set the number of lives you have at the start of the game, add the set life to 3  block.

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)

5 - Create the asteroids

Now let's create a new asteroid sprite every 1 seconds. Add the following code and then use the sprite editor to design your asteroid.

Rename your sprite variable to asteroid and set it to a type of Enemy.

game.onUpdateInterval(1000, function () {
    asteroid = sprites.create(img`
        . . . . . . . . . . . . . . . . 
        . . . . . . d d d d d . . . . . 
        . . . . d d d d d d d d d . . . 
        . . . . d d b b d d b b d . . . 
        . . . . d d d d d d d b d d . . 
        . . . d d b d d d d d b d d d . 
        . . d d d b d d d d d d d d d . 
        . . d d d d d d d d d d d d d . 
        . . d d d d d d d d d d d d . . 
        . . d d d b d d d d b d d . . . 
        . . . d d b d d d b b d d . . . 
        . . . d d d d d b b d d d . . . 
        . . . d d d d d d d d d d . . . 
        . . . . d d d d d d . . . . . . 
        . . . . . . . . . . . . . . . . 
        . . . . . . . . . . . . . . . . 
        `, SpriteKind.Enemy)
})

Join our club 😃

To view the remaining 6 steps and access hundreds of other coding projects please login or create an account.

Copyright Notice
This lesson is copyright of Coding Ireland. 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