Stage 5: Track Score and Progress
Course progressStage 5 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
task collection, score, and a HUD
Learn
how variables update when the game state changes
Ship
visible progress toward winning
The big idea
A HUD turns movement into feedback. When the player completes a task, the screen should prove it immediately.
- HUD
- on-screen information like score or task count
- global
- a keyword that lets a function update a variable outside itself
- remaining
- the items that are still left after a check
- score
- a number that rewards player progress
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.
tasks_done = 0
score = 0
hud = turtle.Turtle()
hud.hideturtle()
hud.penup()
hud.color("white")
def update_hud():
hud.clear()
hud.setposition(0, TOP - 45)
hud.write(f"Tasks: {tasks_done}/{len(tasks) + tasks_done} Score: {score}", align="center", font=("Arial", 16, "bold"))
def check_tasks():
global tasks_done, score, tasks
remaining = []
for task in tasks:
if player.distance(task) < 28:
tasks_done += 1
score += 50
else:
remaining.append(task)
tasks = remaining
update_hud()
update_hud()Trace the idea
- `remaining` starts empty each check.
- Collected tasks do not get copied into `remaining`.
- The HUD clears and rewrites after changes.
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
- A HUD appears near the top.
- Touching a task increases score.
- Collected tasks stop counting again.