Week 3 — Loops: Doing It Again Without Repeating Yourself¶
At a glance
| Date | Friday, August 28, 2026 |
| Unit | 1 — Think Like a Machine |
| Big idea | Loops let a program repeat behavior without copying the same instructions over and over. |
| Goal | Students add repeated motion or repeated spawning to an Arcade project using one clear loop structure. |
| Student accounts needed | None. Projects autosave in the browser. |
| Prep time | 5 minutes |
Why this lesson looks the way it does¶
A mixed 5th–10th grade room can drown in loop vocabulary if you teach every loop at once. Do not. Today has one idea: repeat without copying. In MakeCode Arcade, the cleanest expression is game on update every ... ms, because it maps directly to what games do: every so often, make something happen.
Students may or may not still have last week's project saved on the same Chromebook. That cannot be the lesson's hinge. Let them reopen it if they can; otherwise they rebuild the player in three minutes. The concept is the loop, not file management.
CSTA 2026 standards¶
| Concept area | Connection |
|---|---|
| Algorithms & Design | Repetition can simplify an algorithm and reduce duplicated steps |
| Programming | Loops repeat a set of instructions under program control |
| Data & Analysis | Repeated actions can create patterns that are easier to observe and compare |
| Systems & Security | Timers and update cycles are system behaviors that programs can use |
| Computing & Society | Repeated software behaviors shape user experience, pacing, and attention |
"I can…" objectives¶
By the end of today, students can say:
- I can explain why copying the same block many times is fragile.
- I can use a loop to make something happen repeatedly.
- I can adjust a loop's timing and predict the effect.
- I can find a repeated action in JavaScript.
Teacher prep — the 5-minute version¶
- Open https://arcade.makecode.com and a blank project on the projector.
- Be ready to demo: player sprite, controller movement,
game on update every 1000 ms. - Write on the board:
Last Friday: Events wait for input
Today: Loops repeat without copying
Question: What should happen again and again? - Decide pairs quickly. If a student is on a different device and lost last week's autosave, normalize it.
- Put a timer where students can see the Driver/Navigator swap at 0:24.
Minute-by-minute run sheet¶
0:00–0:04 — Anchor¶
"Last Friday we made a character move and added events — code that waits for a button press. This Friday we add the thing that makes games feel alive: repeated behavior. If a coin appears once, that is a toy. If coins keep appearing, that starts to become a game."
Quick board question:
"Which is better: ten copied blocks, or one block that repeats ten times? Why?"
Take two answers. Land on: fewer places to fix.
0:04–0:12 — Mini-lesson: one repeated action¶
Build or reopen a tiny moving-player project. Add a food/coin sprite inside game on update every 1000 ms; place it at a random x/y.
Say as you build:
"This block is not waiting for a button. It is waiting for time. Every 1000 milliseconds — one second — it runs the instructions inside. If I change 1000 to 250, I did not write more code. I changed the rhythm of the program."
Run it once with 1000 ms, then 250 ms.
"Notice the tradeoff: faster is more exciting, but it can also become chaos. Programmers are constantly choosing rhythms."
Toggle Blocks → JavaScript and point to game.onUpdateInterval.
"Extenders, this is today's code shape. Find the interval number. That number is the heartbeat."
0:12–0:36 — Paired build¶
Students create or reopen a project with a controllable player. Add one loop that repeats something visible.
Required build:
- Player sprite moves with buttons.
- A collectible or obstacle sprite is created.
- A loop changes something repeatedly: spawn, move, bounce, or say a message.
- Students test two different timing numbers.
"Do not build five features. Build one repeated behavior you can explain. If I walk up to your table, I should be able to ask: what repeats, and how often?"
Driver/Navigator swap at 0:24.
"Swap. New Driver, your first job is to change the timing number and predict what will happen before you press Play."
Tiered challenges¶
- 🟢 Starter (gr 5–6): Make a food or coin appear in a new random spot every second.
- 🟡 Builder (gr 7–8): Add an obstacle that appears every 1.5 seconds and moves across the screen. Tune the timing so it is fair, not impossible.
- 🔴 Extender (gr 9–10): Toggle Blocks → JavaScript. Change the interval in
game.onUpdateInterval(...)in code. Add a short comment to yourself in JavaScript explaining what the interval controls, then return to Blocks.
Avoid loop soup
If a pair starts adding every loop block they can find, stop them. Ask them to delete down to one repeated behavior they can describe in a sentence.
0:36–0:42 — Share-out¶
Pick two pairs with different rhythms: one slow/fair, one fast/chaotic.
"What repeats in your game? How often? What changed when you changed the number?"
Ask the room:
"Which version is more fun to play? Which version is easier to understand? Those are not always the same."
0:42–0:45 — Teaser + prompt¶
"Next Friday we need the program to remember something. If your player collects a coin, the game has to keep score. That means variables."
Share-out prompt¶
"What repeats in your program, and what single number changes the rhythm?"
🤔 Think About This¶
Notice one repeated system this week: a traffic light cycle, a school bell schedule, a playlist, a washing machine, a game enemy pattern.
Ask: what would break if the timing changed?
🔌 Unplugged Plan B — if the internet is down¶
Use paper loops and bodies to make repetition physical.
| Time | Activity |
|---|---|
| 0:00–0:04 | Anchor: events waited for buttons; loops repeat behavior. |
| 0:04–0:12 | Copy-paste pain. Write clap, stomp, turn six times on the board. Ask what is annoying if stomp becomes snap. Replace with repeat 6 times: clap, stomp, turn. |
| 0:12–0:24 | Human loop machine. Groups of 3 create a repeated movement pattern. One student is the counter, one is the performer, one is the debugger. |
| 0:24–0:34 | Timed loops. Teacher calls "every 5 seconds" or "every 2 seconds" while groups perform one action. Discuss how rhythm changes difficulty. |
| 0:34–0:41 | Groups write a paper "Arcade loop": Every ___ seconds, create/move/change ___. Trade and act out another group's loop. |
| 0:41–0:45 | Teaser variables and same Think About This. |
The rule: if a direction is copied three times, someone must replace it with a loop.
Common problems & fixes¶
| Problem | Fix |
|---|---|
| Student cannot find last week's project | Have them make a new one. Player + controller movement takes two minutes now. Do not spend class time on recovery. |
| Loop creates hundreds of sprites and slows the game | Increase the interval or reuse one sprite instead of creating a new one every tick. Name it "sprite flood" so students remember. |
| Student puts controller movement inside the timed loop | Move controller setup back to on start. Movement is setup; spawning is repeated behavior. |
| Timing numbers feel mysterious | Translate: 1000 ms = 1 second, 500 ms = half a second, 2000 ms = 2 seconds. Write it on the board. |
| Extender edits JavaScript and blocks look odd | Reassure them. If it still runs, it is fine; if not, undo once and compare. |
Vocabulary¶
- Loop — code that repeats
- Iteration — one pass through a loop
- Interval — the amount of time between repeated actions
- Milliseconds — thousandths of a second; 1000 ms is 1 second
- Pattern — behavior that repeats predictably
Reflection — fill in after class¶
- Did students understand milliseconds, or should that be revisited?
- Which repeated behaviors were playable rather than chaotic?
- Who is ready to edit JavaScript comfortably?
- Did anyone's autosave issue need a pairing adjustment?
Next week: Week 4 — Variables: Keeping Score