Today you will make an enemy sprite chase the player when near, and go back to patrol when the player is far away.
1 Warm-Up
2 Predict
3 Try It
4 Plan
5 Build
6 Fix It
7 Extend
8 Math Challenge
For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 2
✦ CSTA 2-AP-11 · CSTA 2-AP-12 · CSTA 2-AP-13 · ISTE 1.5.c · Standards
| 🎯 I can | make an enemy sprite chase the player when near, and go back to patrol when the player is far away |
| 📝 New words | 6 words |
| ⏱ Lesson time | ~45 min |
Teacher Guide
📋 Before class
⚠️ Common misconceptions
- Students often expect point towards to also move the sprite — it only turns the sprite to face the target. A separate move steps block is needed to move.
- Students think the enemy should chase all the time. Use distance to check: chase only when the player is near, and go back to patrol when the player is far.
🎯 Differentiation
🐢 Struggling: Start with chase only — the enemy always points at the player and moves toward them. Add the patrol and the wall check after the basic chase works.
🚀 Advanced: Make the chase speed depend on distance: the enemy moves faster when the player is far and slower when the player is near.
💡 During the lesson
- Warm-UpAsk students: "If you wanted to catch a friend in a game of tag, how would you move?" (Face them, then run toward them.) That is exactly what
point towardsplusmovedoes. The enemy only needs two simple rules: chase when the player is near, and walk back and forth (patrol) when the player is far. Use a variable to remember which mode the enemy is in. - Try ItThe color
#333399is a placeholder for whatever wall color is on the backdrop. Students must use the eyedropper in the touching color block to sample their actual wall color.
The first experiment makes the job of each block clear — with 0 steps,point towardsonly turns the enemy to face the player, and it never moves. Push students to say which block does which job (turning to face vs. turning at a wall) before moving to the Plan section. - PlanWalk through the three modes before students open Scratch. Ask: "Can the enemy ever go straight from patrol to run away?" (No — run away only happens after chasing and getting stuck.) Keeping the modes clear is the key idea here.
- BuildCommon issue — students put the mode checks in separate when-flag-clicked scripts. This causes problems where one script reads the mode while another changes it. Keep all mode checks in one forever loop on the enemy sprite.
Show the picture first. Ask what will happen — everyone points or says one word.
Everyone picks an answer first. Then press the flag together.
Change one thing at a time. Run it, watch, then change the next thing.
Pairs put the cards in order before anyone opens Scratch.
Students build step by step. Walk around — help with questions, not with the mouse.
Ask: what did we want, and what did it do? Let them find it.
Fast finishers pick the next tier. Everyone else finishes their build.
Work it out on paper first. Then check it on the stage.