Level 6

Chase and Run

Level 6 · Chapter 4

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 6–8

Name variables well and work with their values.

Code 2-AP-11Read the official text

Also practised: 2-AP-12 · 2-AP-13

Common Core State Standards for Mathematics

The Number System · Grade 6

Divide a fraction by a fraction.

Code 6.NS.A.1Read the official text

The short lines are our own words. We matched this lesson to these standards ourselves; the standards' owners have not reviewed or endorsed this course.

Common Core State Standards © 2010 National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

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

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 canmake an enemy sprite chase the player when near, and go back to patrol when the player is far away
📝 New words6 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 towards plus move does. 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 #333399 is 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 towards only 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.