Students build an enemy that chases the player with if … else by comparing positions, then meet the follow block that does the same steering for them.
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 15 min · Make 10 min · Sheepdog 5 min
if … else has two parts and exactly one runs: the first when the question is true, the else part when it is false. else if adds another question, asked only when the ones above were false.
The chaser asks is cat x < mouse x? If yes, the mouse is to the right of the cat, so the cat's vx (speed across) must be positive. Otherwise it is negative (go left). Up and down works the same with y and vy; y counts down, so a mouse lower on the screen has a bigger y and the cat needs a positive vy.
The planted misconception (Zoe's cat) is a swapped sign: the cat runs away. It is easy to make, because "less than" and "go right" do not sound alike. Read it aloud: "if the mouse is to my right, go right."
After students have built the chaser, they meet follow (Sprites), which does the steering in one block. This is "build it yourself, then meet the real tool": they now know what the block does inside. The Make (a patrolling guard) uses else if with no else, so the guard keeps walking in the middle.
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 is the cat with eyes closed. The class calls "left" or "right" every second, depending on which side the mouse is.
Exactly one word each time: that is if … else.
Show your patrolling guard to the next pair. Does it turn at both ends?
Choosing the sign of vx from two positions. Ask them to say in words which side the player is on before choosing positive or negative.
| What you will see | A question to ask | The fix |
|---|---|---|
| The enemy runs away from the player. | If the player is to the enemy's right, should vx be positive or negative? | Positive. Swap the two speeds in the if … else. |
| The guard stops or shakes at one end. | What does each part set vx to, and which way is the guard going when it gets there? | Past 140 it must walk left (negative vx); past 20, right (positive vx). Check both questions use the right edge. |
| The cat only chases across, never up or down. | Which blocks set the cat's vy? | None yet. Add a second if … else that compares cat y with mouse y and sets vy. |
One possible solution for each task. Other correct programs are fine.

scene.setBackgroundColor(7)
let mouse = sprites.create(img`
. . . . d d
. d d d d f
d d d d d d
. d . d . .
`, SpriteKind.Player)
mouse.setPosition(140, 100)
controller.moveSprite(mouse)
mouse.setStayInScreen(true)
let cat = sprites.create(img`
f . . f .
f f f f .
f 5 f 5 f
f f f f f
. f . f .
`, SpriteKind.Enemy)
cat.setPosition(20, 20)
game.onUpdate(function () {
if (cat.x < mouse.x) {
cat.vx = 30
} else {
cat.vx = -30
}
if (cat.y < mouse.y) {
cat.vy = 30
} else {
cat.vy = -30
}
})

scene.setBackgroundColor(7)
let mouse = sprites.create(img`
. . . . d d
. d d d d f
d d d d d d
. d . d . .
`, SpriteKind.Player)
mouse.setPosition(140, 100)
controller.moveSprite(mouse)
mouse.setStayInScreen(true)
let cat = sprites.create(img`
f . . f .
f f f f .
f 5 f 5 f
f f f f f
. f . f .
`, SpriteKind.Enemy)
cat.setPosition(20, 20)
game.onUpdate(function () {
if (cat.x < mouse.x) {
cat.vx = 30
} else {
cat.vx = -30
}
if (cat.y < mouse.y) {
cat.vy = 30
} else {
cat.vy = -30
}
})
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
game.gameOver(false)
})
Open task: any program that does what the step asks.

scene.setBackgroundColor(13)
let guard = sprites.create(img`
. 8 8 .
8 8 8 8
. 1 1 .
. 8 8 .
`, SpriteKind.Enemy)
guard.setPosition(80, 60)
guard.vx = 40
game.onUpdate(function () {
if (guard.x > 140) {
guard.vx = -40
} else if (guard.x < 20) {
guard.vx = 40
}
})
Open task: any program that does what the step asks.
Stretch: Make two guards that patrol at different speeds and heights, and make the game end if either touches the player. Or make a cat that only chases when the mouse is close (an if around the chase).
Support: Give students the first if … else ready-made and ask them to copy it for y. For the guard, give the if and else if with empty questions.
An enemy is at x 100 and the player is at x 30. Should the enemy's vx be positive or negative to chase? Why?
Negative. The player has a smaller x, so it is to the left, and a negative vx moves the enemy left.
Next unit: projectiles and lists, so the player can fight back. Class ideas: a chase game with a cat that speeds up over time; a 'follow the leader' line of ducks using follow; discuss how ghosts in Pac-Man each chase differently.