Building a Flight Simulator with Claude Code, Opus 5

I go out to work on Monday morning
Tuesday, I go off to honeymoon
I’ll be back again before it’s time for sunny-down
I’ll be lazing on a Sunday afternoon

Lazing on a Sunday afternoon, by Queen, Album : Night at the Opera

Last Sunday, I was lazing around, just like in the song, when I realised that my Claude Code and OpenAI subscriptions were suffering from a serious case of “token-idling.” So I decided to put them to work by building a Flight Simulator.

I gave Claude Code a brief specification and let it take off!! It spent the next 25 to 30 minutes combobulating, spelunking, deliberating, moseying and flibbertygibbeting like it always does, while working. Eventually, it returned with a fairly decent 3D Flight Simulator!!!

The simulator was fully rendered in 3D, complete with propeller sounds and basic flight controls. However, all the controls were keyboard-based, and there was almost no useful information displayed on the screen providing visual feedback to the flier.

Out of curiosity, I gave the same specification to Codex to see what it would produce. After another 20 to 30 minutes, it came back with a 2D flight simulator: both the scenery and the aeroplane were rendered in two dimensions. Compared with Claude Code’s version, it was rather underwhelming!! I spent a little more time trying to improve it, but eventually gave up and turned my full attention back to Claude Code & Opus 5.

The initial version of the Flight Simulator built by Claude Code, even though it was in 3D, was quite clunky. There was no visual feedback for the pilot, there was just the Cessna and some rough terrain. Ran into several problems in the initial flights. The controls didn’t seem to work very well.

I ran into the following problems namely

  1. When I would tilt the aircraft nose up (S) for a climb, it would climb indefinitely and then stall, only to come crashing down. This was because the keyboard is all or nothing input, Holding S for a climb used to point the nose up and leave it there, so the aircraft never hunted back toward a trim speed. Airspeed decayed until it stalled and fell out of the sky. Three things fixed it: a nose-down restoring moment proportional to how far AoA has drifted above trim; auto-trim clamped to a −6°…+10° band so it can never trim into a stall.
  2. When I would bank to the left or right (< or ->) , it the plane would initially bank but then it would turn in the opposite direction and continue. The weathervane sign was inverted. The fin should swing the nose into the relative wind, so a slip to the left must yaw the nose left to follow. A single leading minus sign in the sideslip term had it pushing the nose the other way, widening the slip instead of closing it — so the aeroplane flew permanently sideways, and the slip fed straight back into roll.
  3. There were several other smaller issues that made the aircraft difficult to control.

First, I added a Hints box in the top-left corner of the screen. This gives the pilot immediate guidance on what to do at different stages of the flight.

I also added five instruments at the bottom of the screen:

  1. Airspeed
  2. Attitude
  3. Altitude
  4. Climb or Descent
  5. Yoke position

Angle of Attack (AoA) indicator. The angle of attack is the angle between the wing’s chord line and the oncoming airflow. In the simulator, the pilot should generally keep it below approximately 11 degrees to avoid approaching a stall.

The simulator offers two places to fly

  • Queenstown, New Zealand — an alpine lake ringed by mountains, with the town’s buildings and roads
  • Rio de Janeiro, Brazil, with its coastline and bay.

To bring more realism to both, the shape of the terrain comes from real-world elevation data. A one-time build script pulls DEM tiles from AWS Open Data’s Terrain Tiles, which are derived from public-domain SRTM and Copernicus data, and decodes the elevation packed into each pixel’s RGB channels. That gets baked into a compact binary heightmap — a 1024×1024 grid covering 30 km, so roughly one sample every 29 metres — which the browser then loads offline and builds as an 8×8 grid of terrain chunks. Queenstown sits 348 m above sea level with peaks rising nearly 1950 m above the valley floor and about a tenth of the map under water, while Rio de Janeiro is essentially at sea level (4 m) with its own 990 m of relief and a coastline instead of a lake. Since 29 m per sample looks faceted from low altitude, a little procedural noise adds a few metres of micro-relief underneath it, faded out over the runway so landings aren’t fighting bumps. The buildings and roads come from OpenStreetMap rather than from the satellite imagery, for a simple reason: the imagery is 10 m per pixel, so a road is about one pixel wide and no amount of zooming fixes that, whereas coordinates have no resolution and stay sharp at any altitude. Queenstown has 13,504 buildings and 1,648 roads baked in — merged into 67 meshes so the frame isn’t spent on draw calls — along with its real runway, 05/23, 1773 m of asphalt. Rio has none yet: OpenStreetMap lists 118,756 buildings there, which needs filtering and a performance pass before it’s worth attempting.

To see full design details check flight_simulator_1

Check out my piloting skills in the Demo flight on Cessna 172 – Demo flight

The Flight Simulator is quite addictive. Works only on desktop/laptop. Do give it a try! Click Flight Simulator

Hope you have a great time, in the open skies on a Cessna 172!!!

Leave a Reply