Build a Procedurally Generated Maze Escape Game with Timer and Fog of War

You get a single HTML file containing Lantern Labyrinth, a maze game with always-solvable random mazes, three difficulty sizes, a timer, swipe and keyboard controls, and an optional fog-of-war mode.

The prompt

Prompt
Act as a senior front-end game developer who ships polished browser games in a single file. Build Lantern Labyrinth, an original maze escape game where the player guides a glowing lantern from the top-left corner to a mint-green exit in the bottom-right of a procedurally generated maze. Carve every maze with an iterative recursive backtracker (depth-first search using a stack) so it is a perfect maze that is always solvable, and generate a fresh one for each new game.

Rules:
1. Controls: arrow keys or WASD move one cell. Swiping or dragging on the maze slides the lantern straight until it reaches a junction or a wall. Show on-screen D-pad buttons for touch. Tapping the maze steps toward the tap.
2. Difficulty buttons: Easy 10x10, Medium 16x16, Hard 24x24. The timer starts on the first move. Show moves and a best time per difficulty, kept in memory only.
3. A Fog toggle limits sight to a small radius around the lantern and dimly remembers explored cells.
4. Draw on a crisp, devicePixelRatio-aware canvas that resizes to fit frames 360-1280px wide. Use a navy background, pale walls, a gold lantern, a mint exit and a faint gold breadcrumb trail.
5. Show a win overlay with time, moves and a Next maze button. Use smooth gliding movement, turned off under prefers-reduced-motion.
6. Add Web Audio blips for steps and bumps plus a win chime. Create the AudioContext on first input, keep volume low and include a visible mute toggle. No external assets, storage or alerts.

Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.

Example output

One HTML file. Save it and open it in any browser.Open full screen

Example: Lantern Labyrinth, a procedurally generated maze escape.

Guide the gold lantern from the top-left to the glowing mint exit. Use arrow keys or WASD to step one cell. Hold Shift, swipe or drag to slide to the next junction, or use the D-pad on touch screens. Pick Easy, Medium or Hard, then turn on Fog to see only a small circle around you. The timer starts on your first move. Try to beat your best time.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Naming the recursive backtracker guarantees a perfect maze, so every generated level has exactly one path between any two cells and is always solvable.
  • Slide-to-junction swipes make big mazes playable on phones without hundreds of taps, while the keyboard keeps precise single steps.
  • Fog of war with remembered cells adds a memory challenge, so the same difficulty plays differently every round.

Paste into ChatGPT, Claude or Gemini. Save the returned code as lantern-labyrinth.html and open it in any browser, or run it in the chat's preview or canvas panel.

Common edits

  • Change the theme by swapping the CSS color variables and renaming the game, for example a neon circuit board or a hedge garden.
  • Make it harder by adding a 32x32 size to the SIZES array or shrinking the fog radius in RADII.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Simple HTML Games