Lesson 15: Fleet Movement โ Edges + Direction Flip (Matthes Ch 13 ยง4)
Learning Intentions
- Make the fleet move side-to-side and drop at edges, using direction multiplication.
Success Criteria
- My fleet moves right, drops, reverses, repeats.
- I can explain the fleet_direction *= -1 trick.
- I understand why we need break after the first edge hit.
๐ Do Now โ Error of the Day
Predict: if fleet_direction = 1 and we run fleet_direction *= -1, what's the new value? What about after a second *= -1?
๐ I Do โ Teacher Demo
Live-code Alien.check_edges() + Alien.update() using direction. Then _check_fleet_edges() + _change_fleet_direction() on Game. Emphasise the break โ why it matters (one edge hit = one direction change).
๐ค We Do โ Build Together
Class adds the movement code. Fleet slides right, drops 10 px, reverses. Debug weirdness live โ duplicate drops are common.
๐ You Do โ Your Turn
Tune alien_speed + fleet_drop_speed. Find a balance that feels fair. Arcade quests cover *= -1 + break statements.
- Add settings.alien_speed + fleet_direction + fleet_drop_speed
- Alien.update() uses direction in position calc
- Alien.check_edges() returns True/False
- _check_fleet_edges() loops + breaks on first hit
- _change_fleet_direction() drops ALL aliens + flips direction
๐ฎ Practice Quests โ work through these
Loading practice quests for this lesson...
Three tiers โ pick yours
Support
fleet_movement_starter.py with check_edges method pre-written
Core
Follow the plan as written. Attempt the arcade quests above at your own pace.
Extension
Complete all quests above + try a Boss battle for bonus XP. Help a classmate if you finish.
Extensions
- Physical demo: teacher walks left-right-drop in front of class while aliens do the same.
- Diagonal wobble: add small sine-wave y-movement.
๐ Exit Ticket โ Coding Journal
Journal: in 2 sentences, explain why break is critical inside _check_fleet_edges().
Evidence of Learning
Fleet moves right, drops, reverses, drops, reverses โ indefinitely.