Stage 7: Make the Chaser Move
Course progressStage 7 of 10
One game, one Trinket
Keep building in the workspace on the right.
This stage is part of the same Crewmate Task Dash project you started in Setup. Type each new code block into the Trinket rail and keep building on the last stage.
Build
simple chase movement
Learn
how direction and timer loops create motion
Ship
a chaser that slowly follows the player
The big idea
The chaser does not need advanced AI. It can point toward the player, move forward a little, and repeat.
- timer loop
- a function that asks Turtle to run again after a delay
- towards
- a Turtle method that finds the angle to a point or Turtle
- heading
- the direction a Turtle faces
- AI
- game logic that makes a computer-controlled actor seem smart
Tasks 2/4Score 80
The player moves through the ship, collects tasks, and avoids the chaser. All playable shapes are drawn with Python Turtle code.
Build it
Type, run, test
Read the code aloud before you run it. The goal is to understand what changed in the game.
Need a hint?
Add the new code to the same Trinket project. Keep previous stage code unless the stage says to replace a function.
Write this part
main.py
Add this to your current Trinket file.
game_on = True
def move_chaser():
if not game_on:
return
chaser.setheading(chaser.towards(player))
chaser.forward(4)
draw_chaser()
def game_loop():
check_tasks()
move_chaser()
screen.ontimer(game_loop, 80)
game_loop()Trace the idea
- `towards(player)` finds the angle to the player.
- `forward(4)` moves only a little each loop.
- `ontimer` keeps the loop running without blocking key presses.
Try this
Try this
Three short experiments. Predict before you run, then test your guess.
Predict first
Before running, predict which line will visibly change the screen first.
Compare
Change one number, run, then change it back. Which version feels more playable?
Connect
How does this stage make the final game more like a real project?
Test your stage
- The chaser moves.
- The chaser follows the player.
- Arrow keys still work while the loop runs.