L14 ยท T2 Week 7 ๐ŸŽฏ CT5-DPM-01 ยท CT5-THI-01 ๐Ÿ“‚ Phase 2 โ€” Alien Invasion ยท Ch 13 Aliens

Lesson 14: Building the Fleet โ€” Nested Loops + Spacing Math (Matthes Ch 13 ยง3)

Learning Intentions

Success Criteria

๐Ÿ“ Do Now โ€” Error of the Day

Whiteboard challenge โ€” if the screen is 1200 px wide and each alien is 60 px wide (with 60 px gap between), how many aliens fit in a row? Write your calculation.

๐Ÿ‘ I Do โ€” Teacher Demo

Derive the fleet-math formula on the whiteboard. Live-code _create_fleet() with nested for-loops: outer rows, inner columns. Calculate number_aliens_x, number_rows from screen dimensions.

๐Ÿค We Do โ€” Build Together

Class builds the full fleet together. Nested loops. Magical moment when the grid appears. Tune the row/column counts together.

๐Ÿš€ You Do โ€” Your Turn

Try 3 rows of 5, or 2 rows of 10. Which layout do you prefer? Arcade quests cover nested loops + spacing arithmetic.

  • Whiteboard: screen 1200 px wide, alien 60 px โ†’ how many fit with gaps?
  • Write _create_fleet: calculate number_aliens_x from screen width
  • Outer loop: rows. Inner loop: columns. Create Alien, position, add to group
  • Test โ€” you should see a full grid

๐ŸŽฎ Practice Quests โ€” work through these

Loading practice quests for this lesson...

Three tiers โ€” pick yours

Support

_create_fleet skeleton with the math pre-done. Whiteboard grid math diagram

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

๐Ÿ“ Exit Ticket โ€” Coding Journal

Journal: why do we use a NESTED loop (not two separate loops) to build the fleet?

Evidence of Learning

Full fleet visible on screen with consistent even spacing.

โ† PreviousLesson L13โ†‘ HubAll LessonsNext โ†’Lesson L15