← Teacher guide

Read a game

Students read a whole game, match each job to its blocks, and change rules without breaking the game: a review of the course before the final challenge.

Arcade Foundations · Fire · about 40 minutes · Open the student lesson

Classroom resources

Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.

Students will be able to

Timing

Predict and Run 8 min · Investigate 12 min · Modify 8 min · Make 12 min

Before class

This lesson adds nothing new. Garden defender uses every idea in the course: sprites and positions, the controller, velocity, kinds and overlaps, lives, a timer with pick random, an if in on game update, and projectiles. The skill is reading: find the blocks that do one job, then change only those. It prepares students for Space dodger, where they build a game in milestones.

Running the lesson

  1. Predict: the if in on game update, from lesson 7. Ask which block answers it.
  2. Investigate: the match is the map of the game. Keep it on the board for the rest of the lesson.
  3. The 'faster bugs' question separates how often (the timer) from how fast (vy): a common confusion.
  4. Modify: each rule is one number in one block.
  5. Make: a new job touches three places: a timer to make apples, a velocity to move them, an overlap for the catch.

In class

On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.

The hard part (on purpose)

Finding the right block in a longer program. Ask them to name the job first, then point to its block.

When students get stuck

What you will seeA question to askThe fix
The student changes the wrong block.Which job does that block do? Find it in the match.Use the map of jobs to find the block for the rule you want to change.
Apples appear but catching one does nothing.What kind are the apples, and which overlap did you add?Apples are Food; the overlap must be Player and Food.
Catching an apple gives many lives.What happens to the apple after the catch?Destroy it in the overlap, or the event runs every frame.

Answers to the checks

  1. Predict: Read the on game update block. What happens when your score reaches 10?
    The background turns green. on game update asks 'is the score 10 or more?' every frame, so the colour changes the moment you reach 10.
  2. Jobs and blocks: Match each job with the blocks that do it.
    a new bug every 800 ms, at a random x → C. on game update every 800 ms; the gardener moves left and right only → E. move gardener with buttons 100, 0; water goes up when A is pressed → B. projectile from gardener with vy -100; water that hits a bug scores → A. on Projectile overlaps Enemy; a bug that lands on you costs a life → D. on Player overlaps Enemy
  3. Score and lives: The game starts with 3 lives and a score of 0. Fill in the score and lives after each thing happens.
    1, 3, 1, 2, 1, 2
    Only the overlap events change the score or lives. A bug that misses everything changes nothing.
  4. Faster bugs: You want the bugs to fall faster. Which block do you change?
    bug vy, inside the timer
    vy is the bug's speed down. The 800 sets how often bugs come, not how fast they fall.

Solutions

One possible solution for each task. Other correct programs are fine.

Modify › More bugs

The program as blocks
Show as code
let bug: Sprite = null
scene.setBackgroundColor(13)
info.setLife(3)
let gardener = sprites.create(img`
    . 4 4 .
    4 4 4 4
    . 8 8 .
    . 8 8 .
    `, SpriteKind.Player)
gardener.setPosition(80, 110)
controller.moveSprite(gardener, 100, 0)
gardener.setStayInScreen(true)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    let water = sprites.createProjectileFromSprite(img`
        . 9 .
        9 9 9
        . 9 .
        `, gardener, 0, -100)
})
game.onUpdateInterval(400, function () {
    bug = sprites.create(img`
        . 7 7 .
        7 f f 7
        7 7 7 7
        . 7 7 .
        `, SpriteKind.Enemy)
    bug.setPosition(randint(10, 150), 0)
    bug.vy = 30
})
sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Enemy, function (sprite, otherSprite) {
    sprite.destroy()
    otherSprite.destroy()
    info.changeScoreBy(1)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.destroy()
    info.changeLifeBy(-1)
})
game.onUpdate(function () {
    if (info.score() >= 10) {
        scene.setBackgroundColor(7)
    }
})

Modify › Harsher bugs

The program as blocks
Show as code
let bug: Sprite = null
scene.setBackgroundColor(13)
info.setLife(3)
let gardener = sprites.create(img`
    . 4 4 .
    4 4 4 4
    . 8 8 .
    . 8 8 .
    `, SpriteKind.Player)
gardener.setPosition(80, 110)
controller.moveSprite(gardener, 100, 0)
gardener.setStayInScreen(true)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    let water = sprites.createProjectileFromSprite(img`
        . 9 .
        9 9 9
        . 9 .
        `, gardener, 0, -100)
})
game.onUpdateInterval(400, function () {
    bug = sprites.create(img`
        . 7 7 .
        7 f f 7
        7 7 7 7
        . 7 7 .
        `, SpriteKind.Enemy)
    bug.setPosition(randint(10, 150), 0)
    bug.vy = 30
})
sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Enemy, function (sprite, otherSprite) {
    sprite.destroy()
    otherSprite.destroy()
    info.changeScoreBy(1)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.destroy()
    info.changeLifeBy(-2)
})
game.onUpdate(function () {
    if (info.score() >= 10) {
        scene.setBackgroundColor(7)
    }
})

Make

The program as blocks
Show as code
let apple: Sprite = null
let bug: Sprite = null
scene.setBackgroundColor(13)
info.setLife(3)
let gardener = sprites.create(img`
    . 4 4 .
    4 4 4 4
    . 8 8 .
    . 8 8 .
    `, SpriteKind.Player)
gardener.setPosition(80, 110)
controller.moveSprite(gardener, 100, 0)
gardener.setStayInScreen(true)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
    let water = sprites.createProjectileFromSprite(img`
        . 9 .
        9 9 9
        . 9 .
        `, gardener, 0, -100)
})
game.onUpdateInterval(800, function () {
    bug = sprites.create(img`
        . 7 7 .
        7 f f 7
        7 7 7 7
        . 7 7 .
        `, SpriteKind.Enemy)
    bug.setPosition(randint(10, 150), 0)
    bug.vy = 30
})
game.onUpdateInterval(3000, function () {
    apple = sprites.create(img`
        . . 7 .
        . 2 2 .
        2 2 2 2
        . 2 2 .
        `, SpriteKind.Food)
    apple.setPosition(randint(10, 150), 0)
    apple.vy = 25
})
sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Enemy, function (sprite, otherSprite) {
    sprite.destroy()
    otherSprite.destroy()
    info.changeScoreBy(1)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.destroy()
    info.changeLifeBy(-1)
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
    info.changeLifeBy(1)
    otherSprite.destroy()
})
game.onUpdate(function () {
    if (info.score() >= 10) {
        scene.setBackgroundColor(7)
    }
})

Stretch and support

Stretch: Add a second timer that sends a fast bug every 5 seconds. Where does each part of it go?

Support: Give students the apple's timer already made, and ask them only to add the Player–Food overlap.

Exit ticket

In Garden defender, which block would you change to give the player 5 lives at the start?

set life to 3, in on start: change 3 to 5.

What each step is for

Where it leads

Next: Space dodger, the final challenge, built in milestones with less help each time.