DemoCode
Orbit Golf demo

Orbit Golf is 18 holes of 3D mini-golf in space. A green alien golfer putts along walled neon courses that bend, zigzag, and spiral, while real Newtonian gravity from planets, moons, and black holes curves every shot. The ball banks off walls, rolls to a stop, and you play it where it lies, with flying saucers, satellites, and a cheering alien crowd looking on. A solver proves every hole can be finished, and the game works with touch, mouse, and keyboard.

How it works

At every point on the course, the ball's acceleration is the sum of the pull from every massive body, mu · r / |r|³, where mu is the body's gravitational parameter and r the vector from the ball to it. This is plain planar Newtonian gravity with no scripted paths. The simulation runs at a fixed 1/240 second step: velocity-Verlet integration of gravity, then rolling resistance and linear drag, then wall collision that reflects off the nearest edge while keeping part of the speed. Friction is deliberate, so every putt eventually settles. The ball counts as resting only when it is slow and the local gravity is too weak to restart it, and a ball crossing the cup too fast lips out.

The rubber-sheet fairway under the ball is the gravitational potential, computed live in the vertex shader from the same body positions and masses the physics uses. The same clamped function runs in TypeScript, so the ball and bodies sit exactly on the surface the grid shows. It is only a visualisation and does not change the physics.

Moons, saucers, and moving cups ride fixed rails with a set period and phase, driven by one course clock, so a stroke is determined by its lie, its aim, and the clock, and the aim preview is exact. Black holes, saucer beams, and leaving the course are hazards that replay the stroke from where it started. A wormhole carries the ball between two mouths at the same speed and heading.

Every hole is proven finishable. scripts/solve.ts runs a beam search over the same headless simulate function the game uses, sweeping angles and powers and ranking results by a walking-distance field over the fairway. The winning shots are stored in src/game/solutions.ts and replayed by the test suite, which asserts all 18 holes finish at or under par. A Sandbox mode lets you place planets and black holes in a walled room.

Controls

  • Drag left or right to turn the golfer and the view, drag up to add power, and release to putt. A sideways-only drag just looks around.
  • Angle and power nudge buttons fine-tune the aim, and FIRE putts.
  • Keyboard: arrow keys adjust angle and power (hold Shift for 5 times the step), Space or Enter swings, R restarts the hole, and Escape opens the menu.
  • Ten strokes is the limit per hole. Progress and best scores are saved in your browser.

Built with

React 19, TypeScript, and Three.js with custom shaders, built with Vite. Sound is synthesised with Web Audio, and tests use Node's built-in test runner.