🎯Calibrate
1Fill-in
2Debug
3Extend
4Create
🧠Concept
📓Reflect
👤 Your Details REQUIRED — fill in before you begin (★ = required)
🎯 Before You Begin Calibration Check 2 questions + 1 reflection — unlocks Tier 1
Think about what makes a game feel complete: what happens when the player loses, how scores are persisted, and what extra screens or effects would improve the experience.
1 10 5
Tier 1 Fill in the Blanks Complete the code skeleton — 10 blanks

Complete the game-over and high-score system. Fill each blank.

import json, os

SAVE_FILE = "snake_scores.json"

def load_scores():
    if os.path.exists(▢1):
        with open(SAVE_FILE) as f:
            return json.▢2(f)
    return {"high": ▢3}

def save_scores(data):
    with open(SAVE_FILE, ▢4) as f:
        json.dump(data, ▢5)

# In the game update:
scores = load_scores()
if score > scores[▢6]:
    scores["high"] = score
    save_scores(▢7)

# Game-over screen function:
def show_game_over(screen, score, high):
    overlay = pygame.Surface(screen.get_size(), pygame.▢8)
    overlay.fill((0, 0, 0, ▢9))
    screen.blit(overlay, (0, 0))
    # render text centred on screen
    pygame.display.▢10()
1.Blank 1: S________
2.Blank 2: l___
3.Blank 3: _
4.Blank 4: "__
5.Blank 5: _
6.Blank 6: "_____
7.Blank 7: s_____
8.Blank 8: S_______
9.Blank 9: 1__
10.Blank 10: f___
Tier 2 Find & Fix the Bugs 3 bugs to correct

The game-over / high-score code below has 3 bugs. Type the corrected line for each.

import json, os

def load_scores():
    if os.path.exists("snake_scores.json"):
        with open("snake_scores.json") as f:
            return json.loads(f)     # Bug 1 – wrong method

def save_scores(data):
    with open("snake_scores.json") as f:   # Bug 2 – wrong file mode
        json.dump(data, f)

scores = load_scores()
if score > scores["high"]:
    scores["high"] = score
    save_scores(scores)
    score = 0                        # Bug 3 – resets score before showing it

Bug 1

Buggy line:

return json.loads(f)

Your fix:

Hint: `json.loads()` parses a string. `json.load()` reads directly from a file object.

Bug 2

Buggy line:

with open("snake_scores.json") as f:

Your fix:

Hint: Writing requires "w" mode. Without it, `open()` defaults to read-only and `json.dump()` will raise an error.

Bug 3

Buggy line:

score = 0 # after saving high score

Your fix:

Hint: Resetting score here wipes the value before it can be displayed on the game-over screen. Reset at game restart instead.

Reflection 2 Mid-Point Check-In
Tier 3 Extend the Code Add the feature described below

Build a **game-over overlay**: a semi-transparent black surface drawn over the screen, showing "GAME OVER", the final score, and the high score. Pressing SPACE or ENTER restarts.

def show_game_over(screen, score, high_score):
    """Draw a game-over overlay and wait for SPACE/ENTER to restart."""
    overlay = pygame.Surface(screen.get_size(), pygame.SRCALPHA)
    overlay.fill((0, 0, 0, 180))
    screen.blit(overlay, (0, 0))

    # YOUR CODE: render "GAME OVER", score, high_score centred on screen
    # YOUR CODE: call pygame.display.flip() then wait for SPACE/ENTER key

    pass
Tier 4 Create from Scratch Open-ended challenge

**Challenge:** Package the complete game — Snake class, Game class, game-over screen, persistent high score — into a single clean `snake.py` file. Write comments explaining each major section. Paste the full file or a detailed outline with key code snippets.

🧠 Concept Check Test Your Understanding 5 quick questions — required before the Reflective Journal 🔒

Answer all 5 questions, then the Reflective Journal will unlock.

1. Replacing the literal 30 with CELL_SIZE = 30 throughout the code is better because:

2. What does a # TODO: add sound comment indicate?

3. Moving snake-drawing code into a draw_snake() function is an example of:

4. A helper function grid_to_pixel(col, row) is useful because:

5. Which of these is NOT a benefit of using named constants?

📓 Reflective Journal 5 prompts — required before Step 9 is marked complete 🔒

Answer each prompt thoughtfully. There are no right or wrong answers — this is your own reflection.

🎯 Post-Activity Check-In After Completing All Tiers Complete after the Reflective Journal to finish this step 🔒
1. How confident do you feel about this step’s concepts now? (1 = not confident, 10 = very confident)
1 10 5
2. Your Tier 1 first-attempt score (auto-filled)
%