Session 2: Coach notes
Goal of this session
After the Basic checkpoint a ninja can:
- Create and manage a list of meteors.
- Make meteors spawn, move and disappear when they fall off the screen.
- Subtract lives on a collision and stop when all the lives are gone.
Dojo Defender starts today. Ninjas add their spaceship to the bigger project.
Preparation (30 min before the session)
- Starter ZIPs ready on USB and the site:
starter.zipanddojo-defender-s2.zip. - Dojo Defender briefing to prepare: explain that this project grows every session and that it pays off to keep showing up.
- Run the starter once yourself on the dojo room laptop.
Schedule (3 hours)
| Time | Activity |
|---|---|
| 0:00 to 0:10 | Looking back at session 1 + intro to meteors |
| 0:10 to 0:25 | Step 1: spawn_meteor() |
| 0:25 to 1:00 | Step 2: moving + collision |
| 1:00 to 1:45 | Step 3 to 4: game over, speed, score |
| 1:45 to 2:15 | Dojo Defender intro + moving the spaceship |
| 2:15 to 2:45 | Buffer / stretch / expert |
| 2:45 to 3:00 | Showcase + cliffhanger |
Common questions
“My list keeps getting bigger and the game slows down”
The meteors aren’t being removed. Check whether the remove() call is correct and whether the loop goes over meteors[:] (a copy), not over meteors itself.
“global lives gives an error”
global has to be at the top of the function, before the first time the variable is used.
“The meteors all start in the same spot”
random.randint is outside the function. Move it inside spawn_meteor().
Hints for Stretch and Expert
Stretch: game over
Set game_over = True in the collision code when lives <= 0. In update() you check it as the first line: if game_over: return.
Stretch: speed
snelheid = 3 + score // 5 works fine. Watch out for values that get too big at high scores. Build in a maximum: min(snelheid, 12).
Expert: score
Raise the score in update() every 60 frames, not on every collision. Use the same timer variable.
Cliffhanger script
“Today you dodged meteors. Next time you have a weapon. Your ship SHOOTS BACK, and enemies are waiting in formation.”
Dojo Defender today
Ninjas copy the movement code from the dodge game into the Dojo Defender starter (download from the site). Make sure everyone understands that this is a separate file that they keep up every session. Advise them to save it in a separate folder, not mixed in with the session starter. The complete Dojo Defender coach notes are on the Dojo Defender page.