Skip to content

Latest commit

 

History

History
48 lines (40 loc) · 1.14 KB

File metadata and controls

48 lines (40 loc) · 1.14 KB

Week 14 – Student Tasks: Explorer

Task A: Run and test

  1. Run week14.py
  2. Use arrow keys to move the circle
  3. Try moving diagonally (hold two keys at once!)
  4. Try to move off the edge - it stops at the boundary

Task B: Modifications

  1. Change speed = 4 to speed = 8 (faster movement)
  2. Change player color to "red" or "yellow"
  3. Change player size from 10 to 15
  4. Change background color in screen.fill()

Task C: Add speed boost

Hold spacebar to move faster:

def update():
    global x, y
    current_speed = speed
    if keyboard.space:
        current_speed = speed * 2  # Double speed!
    
    if keyboard.left:
        x -= current_speed
    # ... rest of movement

Task D: Leave a trail

# At top:
trail = []  # List to store positions

# In update(), after moving:
trail.append((x, y))
if len(trail) > 50:  # Keep last 50 positions
    trail.pop(0)

# In draw(), before drawing player:
for pos in trail:
    screen.draw.circle(pos, 5, "gray")

Success checklist

  • Smooth movement in all 4 directions
  • Can move diagonally
  • Player stays on screen
  • Added speed boost or trail