Level 3

How Far Away?

Level 3 · Chapter 6

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 3–5

Use events, loops and if-then in one program.

Code 1B-AP-10Read the official text

Also practised: 1B-AP-15

Common Core State Standards for Mathematics

Measurement & Data · Grade 4

Change units and solve measuring problems.

Code 4.MD.A.2Read 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 detect how far a sprite is from another sprite or mouse.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 1B
✦ CSTA 1B-AP-10 · CSTA 1B-AP-15 · ISTE 1.5.a · Standards
🎯 I candetect how far a sprite is from another sprite or mouse
🧩 New blocks1 block
📝 New words6 words
⏱ Lesson time~40 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students use (distance to [mouse-pointer ▾]) directly inside if <> without a comparison — distance is a number, not a true/false value.
  • Students expect smaller numbers to mean 'far away.' Remind them: 0 pixels = touching, 200 pixels = very far.

🎯 Differentiation

🐢 Struggling: Draw two dots on paper labeled 'Cat' and 'Mouse.' Measure the gap with a ruler. Explain that Scratch measures the same gap in pixels.

🚀 Advanced: Add a second sprite (Dog2). Use distance to [Dog2 ▾] — cat reacts differently to dog vs. mouse. Chain two if blocks.

💡 During the lesson

  • Warm-UpAsk students: "How does a car know it is near a wall?" Accept answers. Introduce the word "sensor." Tell them their code will be a sensor today. Optionally, hold up a ruler and ask: "How do we measure distance?" (Units — in Scratch they are pixels.)
    Ask: "What is the cat doing in frame 2?" (Waiting, measuring.) "What changed in frame 3?" (The mouse came close — the distance dropped below 50 pixels.) Students should point to the frame that shows the condition becoming true.
  • Try ItHold up distance to [mouse-pointer ▾]. It is a round block — a number. It reports how many pixels away the mouse is, updated every loop. Pair it with < (50) to ask a true/false question.
    Ask: "In the third experiment, what new thing happens?" (The cat grows.) Reset the size with set size to (100) % at the start if students want to retry. Connect to a parking sensor: not only does it beep, the beep gets louder as the car comes near — two reactions to one condition.
  • PlanDo the first box together. Pick, then watch both stages. After the plan, ask: "What happens if the mouse is 60 pixels away?" (Nothing — condition is false, the loop just keeps checking.) This reinforces the loop-and-check pattern.
  • BuildMost common error: students try to drop distance to straight into the if slot — it will not snap in, because the round block does not fit the six-side hole. Show them: distance to has a round shape (number), but if needs a six-side shape (true/false). They must connect the round block to a comparison block first.