Build a Sliding Number Puzzle Game with Solvable Shuffles in One HTML File

A ready-to-paste prompt that builds Tidepool Tiles, a 3x3 to 5x5 sliding number puzzle with parity-checked solvable shuffles, a move counter, a timer, and tap, swipe and arrow-key controls.

You getone complete HTML file in a single code block, then 3 short ideas to extend it.

The prompt

Prompt
You are a front-end game developer who writes clean, dependency-free JavaScript. Build Tidepool Tiles, an ocean-themed sliding number puzzle, as one HTML file. The board is a square grid of numbered sand-colored tiles with one empty gap. The player slides tiles into the gap until the numbers read in order with the gap in the bottom-right corner.

Rules:
1. Offer 3x3, 4x4 and 5x5 size buttons. Every shuffle must be solvable. Count inversions and apply the standard parity rule, including the gap's row from the bottom on even grids. Fix unsolvable layouts by swapping two numbered tiles, and never start already solved. Show a one-line note with the inversion count.
2. Controls: tap a tile in the gap's row or column to slide it and any tiles between. Swipe the board to push a neighbor into the gap, or use arrow keys and WASD. Tiles are focusable buttons with aria-labels.
3. Show moves, a timer that starts on the first move, and an in-memory best per size. Show a win panel with a Play again button.
4. Palette: deep navy background, sand tiles, coral accent, and sea green for tiles in their home spot. Animate slides with transforms and turn the animation off under prefers-reduced-motion.
5. Synthesize soft slide and win sounds with Web Audio. Create the audio on the first input and include a visible mute toggle.
6. Use no external resources, storage, alerts or forms. The layout must fit 360-1280px wide.

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: Tidepool Tiles, an ocean-themed sliding number puzzle.

Pick a 3×3, 4×4 or 5×5 board and get a shuffle that is guaranteed to be solvable. The note under the board shows the parity check.

  • Tap any tile in the gap's row or column to slide it, along with any tiles in between.
  • Swipe the board, or press the arrow keys or WASD.
  • N reshuffles, 3–5 change the size and M mutes.

Tiles turn sea green once they sit in their home spot. Try beating your best move count on 4×4.

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

Tips and common edits

Why this works

  • Spelling out the inversion and blank-row parity rule means the model writes a real solvability check instead of risking impossible boards.
  • Positioning tiles with transforms on fixed buttons keeps keyboard focus stable and gives smooth slides that are easy to turn off.
  • Naming every input path (tap, swipe, arrows, WASD) up front stops the model from shipping a mouse-only puzzle.

Paste the prompt into ChatGPT, Claude or Gemini. Save the returned code as tidepool-tiles.html and open it in any browser, or run it in the chat's preview or canvas pane.

Common edits

  • Swap the theme: change the name, emoji and four palette colors to make a space or forest version, or show picture fragments instead of numbers.
  • Change the difficulty with a 6x6 size button, or add a move limit and a par score for each board size.

Prompt details

By
Prompts-GPT editors
Published

Did this prompt work?

Keep exploring

More in Simple HTML Games