Skip to content
Game 7 16 Units

Treasure Hunt

A real-time grid game with coins, hazards, levels, and a countdown timer.

What You’ll Build

A real-time game where you move a character around a grid, collecting coins and avoiding hazards. A timer counts down. Clear all the coins to advance to the next level — each one harder than the last.

Treasure Hunt gameplay — coins, hazards, and a countdown timer

Why This Game?

Everything you’ve built so far has been turn-based. The computer waits for you to type something, then responds. Real games don’t work like that. In a real game, things happen continuously — the screen updates, hazards move, time runs out.

Treasure Hunt is your first game loop. Instead of waiting for input, the program checks for a keypress on every pass through the loop. If nothing is pressed, it carries on anyway. This is how every real-time game works, from Pac-Man to Fortnite.

What You’ll Learn

  • The game loop — input, update, draw, repeat
  • INKEY$ — polling for keypresses without blocking
  • Character movement — erase old position, draw new
  • Boundary checking — keeping the player on screen
  • ATTR — reading the colour of a screen cell
  • Collision detection — checking what the player walked into
  • GO SUB / RETURN — organising code into subroutines
  • Lives and hazards — losing a life, resetting position
  • Level progression — harder each time
  • PEEK timer — reading the system clock for countdowns
  • Moving hazards — animated obstacles in the game loop
  • Wall collision — using ATTR to detect walls
  • Sound effects — BEEP for game events
  • Visual design — black background, coloured elements
  • Title screens — instructions before the game starts

Prerequisites

Complete Game 6: Quiz Master first. You’ll need arrays, AND/OR, DATA/READ, and RESTORE.

Time Investment

16 units at 45-75 minutes each. Roughly 12-20 hours total.

Unit Roadmap

16 of 16 units available