Students use a timer event to make a new enemy every second, from a random height, and see that both the timer and pick random run again each time.
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.
Predict and Run 7 min · Investigate 10 min · Modify 8 min · Mix it up 3 min · Make 13 min · Rain dodger 4 min
on game update every 1000 ms (Game) is a timer event: it runs its blocks again every so many milliseconds (1000 ms = 1 second) for as long as the game lasts. Here it makes a new enemy each time, at x 160 (the right edge), with a negative vx so it flies left. pick random (Math) gives a new whole number each time it runs, so inside the timer each rock gets its own height. start countdown (Info) ends the game after so many seconds. Try the Make yourself: about 15 blocks.
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 class claps once a second. On each clap, one student rolls a dice and calls out a height.
A new roll every clap: that is pick random inside the timer. Rolling once at the start is Ava's bug.
Seeing that the blocks inside a timer run again and again. Ask how many times the create block has run after five seconds.
| What you will see | A question to ask | The fix |
|---|---|---|
| Only one enemy ever appears. | Is the create block inside the timer, or in on start? | Move it into on game update every 1000 ms, so a new one is made each second. |
| No enemies appear. | Where does each enemy start, and which way does it move? | Start at x 160 and give a negative vx. With a positive vx it leaves the screen to the right at once. |
| Every rock comes at the same height. | Where is pick random? | Put it inside the timer, in the set position block, so it runs for every rock. |
One possible solution for each task. Other correct programs are fine.

let rock: Sprite = null
let mySprite = sprites.create(@IMG:mySprite@, SpriteKind.Player)
mySprite.setPosition(20, 60)
controller.moveSprite(mySprite)
game.onUpdateInterval(500, function () {
rock = sprites.create(@IMG:rock@, SpriteKind.Enemy)
rock.setPosition(160, 60)
rock.vx = -50
})

let rock: Sprite = null
let mySprite = sprites.create(@IMG:mySprite@, SpriteKind.Player)
mySprite.setPosition(20, 60)
controller.moveSprite(mySprite)
game.onUpdateInterval(500, function () {
rock = sprites.create(@IMG:rock@, SpriteKind.Enemy)
rock.setPosition(160, randint(10, 110))
rock.vx = -50
})

let bat: Sprite = null
info.setLife(3)
info.startCountdown(30)
let mySprite = sprites.create(@IMG:mySprite@, SpriteKind.Player)
mySprite.setPosition(20, 60)
controller.moveSprite(mySprite)
mySprite.setStayInScreen(true)
game.onUpdateInterval(1000, function () {
bat = sprites.create(@IMG:bat@, SpriteKind.Enemy)
bat.setPosition(160, randint(10, 110))
bat.vx = -60
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
info.changeLifeBy(-1)
otherSprite.destroy()
})
Open task: any program that does what the step asks.
Stretch: Make the game a win if you survive: add on countdown end (Info) with game over (win).
Support: Give students the timer block with the enemy already inside, and ask them to add lives, the countdown and the overlap event.
A timer runs every 2000 ms and makes one enemy each time. How many enemies after 10 seconds?
5. It runs once every two seconds.
Next unit the game decides things every frame: if a sprite leaves the screen, wrap it round. Class idea: vote on the fairest number of lives and timer speed.