Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 1.11 KB

File metadata and controls

34 lines (29 loc) · 1.11 KB

Week 14 – Explorer (Keyboard-Controlled Movement)

Objectives

  • Use keyboard object for smooth continuous movement
  • Implement boundary checking to keep player on screen
  • Understand difference between keyboard state vs keyboard events
  • Enable diagonal movement

Key Concept: Keyboard State Checking

if keyboard.left:    # TRUE while key is held
    x -= speed       # Move every frame

vs event-based (Week 9 Turtle style):

def on_key_down():   # Called once per press
    x -= speed       # Move once

Lesson flow (60 min)

  1. Warm-up (10 min): Compare Turtle movement to Pygame Zero
  2. Teach (15 min): keyboard object, boundary checking with max/min
  3. Build (20 min): Add all 4 directions, test boundaries
  4. Challenge (15 min): Add speed control, trail effect, second player

Common Student Challenges

  • Forgetting global x, y
  • Boundary math: max(10, min(WIDTH-10, x)) confusing at first
  • Expecting instant response (it IS instant - 60 FPS!)

Success Criteria

  • Smooth 4-direction movement
  • Player stays on screen
  • Can add speed modifier (shift key makes faster)