Build an Orbital Gravity Slingshot Game in a Single HTML File

Create Perihelion, an offline HTML5 canvas arcade game with inverse-square gravity physics, live trajectory previews, and slingshot combo scoring.

Text prompt for ChatGPT and Claude

The prompt

Prompt
Act as a senior HTML5 game developer. Build Perihelion, an original orbital gravity slingshot arcade game in a single self-contained HTML file. The player launches a space probe past glowing gravity wells to reach a target gate across procedurally generated sectors. Follow these rules: 1) Simulate real inverse-square gravity physics on an HTML5 canvas with a live dotted trajectory preview when aiming. 2) Support both mouse or touch drag-to-aim and keyboard controls using Left and Right arrows for angle, Up and Down for power, and Space to launch. 3) Award slingshot combo multipliers when the probe curves close to a gravity well without crashing into its core. 4) Include a compact top HUD showing Sector, Score, Shots left, Combo, and Mute and Reset buttons. 5) Synthesize launch, slingshot chime, target hit, and crash sounds with the Web Audio API after the first user interaction, keeping volume low. 6) Fit cleanly in 360px to 1280px viewports with high-contrast deep-space colors, no external assets, no localStorage, and reduced motion support. 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 (opens in a new tab)
How a Perihelion run playsAim, bend the path, then reach the target gate
  1. Aim the probeDrag on the canvas, or use Arrow keys
  2. LaunchRelease the drag or press Space
  3. Read the trajectoryDotted arc bends around amber gravity wells
  4. Slingshot comboCurve tightly through a well's outer ring
  5. Hit the target gateReach the emerald gate to finish

Example: Perihelion, an orbital gravity slingshot arcade game on HTML5 canvas.

Drag anywhere on the canvas (or use Arrow keys + Space) to aim and launch your probe. Watch the live dotted trajectory arc bend around amber gravity wells. Curve tightly through a well's outer ring to trigger a Slingshot Combo multiplier before hitting the emerald target gate.

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

Tips and common edits

Why this works

  • Uses the exact same inverse-square physics step for both the live trajectory preview and actual flight so shots behave predictably.
  • Combines pointer drag-to-aim with full keyboard controls so the game plays smoothly on mobile touchscreens and desktop browsers.
  • Wraps all state and Web Audio synthesis inside an IIFE with zero external dependencies or storage calls for instant sandboxed execution.

Paste the prompt into Gemini, ChatGPT, or Claude, then save the generated code as an .html file and open it in any browser—or preview it directly in Canvas or Artifacts.

Common edits

  • Add moving or binary gravity wells in higher sectors to create dynamic orbital timing puzzles.
  • Swap the deep-space palette for a minimalist blueprint or neon wireframe theme by updating the canvas color constants.

Reuse it: Use in a workflowTurn into a skillAdapt in the builder

Simple HTML Games

Build a Four-Lane Rhythm Tap Game with a Generated Beat in One HTML File

A ready-to-paste prompt that builds a complete four-lane rhythm tap game with a live Web Audio beat, Perfect/Good/Miss timing grades, combo scoring and a results screen.

Simple HTML Games

Build a Garden Caterpillar Snake Game with Swipe and Wrap Mode in HTML

A prompt that produces Leafline, an original snake-style game where a caterpillar eats garden leaves, with swipe controls, buffered turns, wrap mode and a speed slider.

Simple HTML Games

Build a Match-Three Tile Swapping Puzzle with Cascades and Combo Scoring

Generates a complete single-file match-three puzzle with swap validation, gravity refill, chain-reaction combo scoring and an automatic reshuffle when no moves remain.

Simple HTML Games

Build a Tower Stacking Game with Slice-Off Blocks in a Single HTML File

A ready-to-paste prompt that builds a one-tap tower stacking game where overhangs are sliced off, perfect drops restore width, and the camera follows the tower upward.

Simple HTML Games

Build a Neon Circuit-Routing Tile Puzzle Game in One HTML File

Create VoltGrid, a self-contained neon circuit-routing puzzle game with guaranteed solvable levels, par tracking, and Web Audio lock-in clicks.

Simple HTML Games

Build a Word-Chain Ladder Puzzle Game with Hints in One HTML File

Create RungCraft, an offline word-ladder puzzle game with a built-in dictionary graph, BFS shortest-path par, step-by-step hints, and move efficiency ratings.