logo

Newton's Cannon: A Gravity Simulator in Arcade ECS

A build-along course that writes a small gravity simulator from the real BabylonJS Market components: Newton's cannon fires balls around a planet, the exact orbit is drawn from the equations beside the simulated one, and a moon shows where the formula ends and the simulation keeps going.

What We Will Cover

  • Fire Newton's cannon and watch the shots go from landing to orbit to escape
  • The two lines of code that keep an orbit closed, and what happens when you swap them
  • The exact orbit drawn from the two-body equations, with Galileo's parabola beside it
  • An aim line the balls follow exactly, because it runs the simulation's own step
  • Every code block is the actual published component source

This is Course 1 of the Newton to Space Golf series. You start from an empty create-arcade project and build a classical gravity simulator one component at a time: a camera that frames an orbit on any window, a planet with Newton's inverse-square pull, a ball that falls and then falls around, a cannon that fires from a pool, the exact orbit drawn from the equations, Galileo's parabola beside it, an aim line that runs the real step ahead of time, equal-time ticks from Kepler's equation, and a moon that breaks the formula and hands out a slingshot. Every lesson pairs one scene change with one decision in the real code, tells the true story behind the idea, and has you break the code on purpose to see why it is written that way. Every code block is the actual published component source. Course 2 turns the planet into a black hole.

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search