Students put an if inside on game update to make wrap-around and a safe zone, and find that an if in on start is asked only once.
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 8 min · Investigate 12 min · Modify 12 min · Make 10 min · Lift 3 min
An if block asks a yes-or-no question (a condition), such as car x > 160. When the answer is yes (true), it runs the blocks inside; when no (false), it skips them.
The new idea is when the question is asked. A game draws the screen again about 30 times a second; each drawing is a frame. on game update runs its blocks once every frame, so an if inside it is asked over and over, and acts the moment the answer becomes yes. on start runs its blocks once, before the game begins. An if there is asked one time and then forgotten: this is the planted misconception (Sam's version).
Remember y counts down the screen, so "near the top" is a small y. The comparison block is in Logic; the car x block is in Sprites. Try the Make task yourself first.
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.
One student walks across the room. Another asks "past the door yet?" every second, and calls "back to start!" the moment the answer is yes.
Asking once at the start would never catch it: that is Sam's if in on start.
An if in on start is asked once; in on game update it's asked every frame. When the if never acts, ask which block it is inside.
| What you will see | A question to ask | The fix |
|---|---|---|
| The if never does anything. | Which block is your if inside: on start or on game update? | on start asks once, before anything moves. Drag the if into on game update. |
| The safe zone colour comes on at the bottom of the screen. | Which way does y count? | Down from the top, so near the top is y < 30, not y > 90. |
| The score shoots up while the car is still on the screen. | Is change score inside the if, or just inside on game update? | Outside the if, it runs every frame. Drag it inside the if, under set car x to 0. |
One possible solution for each task. Other correct programs are fine.

scene.setBackgroundColor(7)
let car = sprites.create(img`
. . 2 2 2 2 . .
. 2 9 9 2 9 2 .
2 2 2 2 2 2 2 2
. f . . . . f .
`, SpriteKind.Player)
car.setPosition(80, 60)
controller.moveSprite(car, 100, 0)
game.onUpdate(function () {
if (car.x > 160) {
car.x = 0
}
if (car.x < 0) {
car.x = 160
}
})

scene.setBackgroundColor(7)
let car = sprites.create(img`
. . 2 2 2 2 . .
. 2 9 9 2 9 2 .
2 2 2 2 2 2 2 2
. f . . . . f .
`, SpriteKind.Player)
car.setPosition(80, 60)
controller.moveSprite(car, 100, 0)
info.setScore(0)
game.onUpdate(function () {
if (car.x > 160) {
car.x = 0
info.changeScoreBy(1)
}
})

scene.setBackgroundColor(7)
let hero = sprites.create(img`
. 4 4 .
4 4 4 4
. 8 8 .
. 8 8 .
`, SpriteKind.Player)
hero.setPosition(80, 100)
controller.moveSprite(hero)
hero.setStayInScreen(true)
game.onUpdate(function () {
if (hero.y < 30) {
scene.setBackgroundColor(9)
}
if (hero.y >= 30) {
scene.setBackgroundColor(7)
}
})
Open task: any program that does what the step asks.
Stretch: Make the safe zone a box in the middle of the screen: the hero is safe only when x and y are both inside it (an if inside an if).
Support: Give students the on game update block with an empty if already in it, and ask them only to build the question and choose the colour.
Why does an if that checks 'player x > 150' work in on game update but not in on start?
on game update runs every frame, so the question keeps being asked while the player moves. on start runs once, before the game begins, so the question is asked one time and never again.
Next lesson: else, and an enemy that chases you by comparing its position with yours. Class ideas: a screen where all four edges wrap (like Asteroids); a 'lava floor' that changes colour when the player is near the bottom.