Lesson goal: Lunar Lander: Gravity & Retro-Thrust

Previous: Pac-Man (advanced ideas) | Home | Next: Breakout: Reflection Angles & Paddle

In 1979, Atari released Lunar Lander, engineered by Howard Delman and Rich Moore. It was Atari's very first vector-graphics arcade game!

Instead of fantasy physics, the game is built entirely on real Newtonian mechanics: gravity constantly pulls your lunar module down toward the rocky moon surface, and you must fire your retro-thruster rockets to slow down for a gentle touchdown!

Coordinates, Gravity & Safe Landing

The lunar sector is a 2D Cartesian plane ($600 \times 400$):
  • Width ($x$): $0$ to $600$ pixels (left to right). The landing pad is centered at $x = 300$.
  • Altitude ($y$): $0$ at the top, increasing downward toward the green landing pad at $y = 360$.
  • Gravity ($g$): Constant downward acceleration of $24\text{ px/s}^2$ pulling the lander down.
  • Main Thruster ($a_T$): Produces $70\text{ px/s}^2$ of thrust in the direction the lander is pointing. When pointing straight up, net upward acceleration is: $$a_{\text{net}} = a_T - g = 70 - 24 = 46\text{ px/s}^2$$
  • Safe Landing Criteria: To touch down safely on the pad, your downward speed $V_y$ must be less than $1.5\text{ m/s}$ (about $30\text{ px/s}$), and your tilt angle must be within $10^\circ$ of vertical. Touch down too fast and the lander crashes!


Controlling Your Lander with Code

Instead of twitch arcade joystick controls, you program flight commands:
  • lander_game(n): Initializes deterministic Sector #$n$. Every run with game #$n$ produces 100% reproducible physics!
  • thrust(seconds): Fires the main retro-rocket for seconds (e.g. thrust(1.5)).
  • turn(deg): Tilts the lander by deg degrees. Positive turns right, negative turns left.
  • turn_to(deg): Sets the lander to an absolute angle ($0^\circ$ is straight UP).
  • wait(seconds): Coasts / free-falls under lunar gravity without burning any fuel.
  • aim(x, y): Points the lander directly toward coordinate $(x, y)$.
lander_game(1)
wait(1.8)

thrust(2.2)
Move the mouse over a dotted box for more information.

  • Live Telemetry HUD: The instruments at the top display your altitude, vertical speed ($V_y$), lateral speed ($V_x$), tilt angle, and remaining fuel gauge.
  • Safe Speed Guide: If your downward velocity is safe for touchdown ($V_y \le 1.5\text{ m/s}$), the indicator glows bright green! If you are falling too fast, it turns red.
  • Manual Flying: You can also pilot with the keyboard: ← / → to rotate and ↑ to burn thrusters!

Now you try. Can you land safely in Sector #1, or try lander_game(2) to practice countering horizontal crosswinds?

Type your code here:


See your results here: