Lesson goal: Artillery: Parabolic Ballistics & Wind Drift

Previous: Missile Command: Intercept Kinematics & Blast Geometry | Home | Next: Frogger: Periodic Traffic & Relative Velocity

In 1638, Italian polymath Galileo Galilei published his groundbreaking Dialogues Concerning Two New Sciences, mathematically proving for the first time that any projectile influenced by gravity traces out a perfect parabola!

Centuries later in 1976, Mike Forman programmed the seminal video game Artillery, which inspired legendary classics like Tank Wars, Scorched Earth, and Microsoft's QBasic Gorillas.

Behind every successful long-range bombardment is vector kinematics: decomposing muzzle velocity into horizontal and vertical components, computing apex apogees, and compensating for elevation and wind drift!

The Ballistics Coordinate Grid ($600 \times 380$)

The terrain is a 2D Cartesian plane:
  • Gravity: Downward acceleration $g = 160\text{ px/s}^2$ pulling the shell downward.
  • Player Cannon: Located on the left at $x = 80$, resting atop the procedural terrain.
  • Target Fortress: Located on the right at $x = 480$, awaiting counter-battery fire.
  • Muzzle Velocity Decomposition: Firing with power $P$ at angle $\theta$ launches the shell with initial velocity $v_0 = 3.6 \times P$: $$v_{0x} = v_0 \cos(\theta), \quad v_{0y} = -v_0 \sin(\theta)$$


The Parabolic Flight Equations

With horizontal wind drift acceleration $w$ and downward gravity $g$: $$x(t) = x_0 + v_{0x} t + \frac{1}{2} w t^2$$ $$y(t) = y_0 + v_{0y} t + \frac{1}{2} g t^2$$ On level ground ($\Delta y = 0$) with calm wind ($w = 0$), the horizontal range simplifies to the famous formula: $$R = \frac{v_0^2 \sin(2\theta)}{g}$$ Because $\sin(2\theta)$ peaks when $2\theta = 90^\circ$, the maximum theoretical range in a vacuum occurs at $\theta = 45^\circ$!

Elevation Offsets & Wind Vectors

  • High Altitude Targets ($\Delta y < 0$): When firing uphill at a fortress atop a cliff, the shell must carry extra vertical velocity, shifting the optimal angle steeper (e.g. $58^\circ$).
  • Headwinds ($w < 0$): A negative horizontal wind vector retards the shell's forward progress, requiring lower penetrating trajectory angles (e.g. $38^\circ$) with higher initial kinetic energy.


Controlling the Artillery Cannon with Code

Program your fire control computer using deterministic Lua commands:
  • artillery_game(n): Initializes deterministic Stage #$n$ (1: Flat Range, 2: High Elevation, 3: Headwind, 4: High Mortar Lob).
  • aim(degrees): Sets the barrel elevation angle in degrees ($0^\circ$ = horizontal, $45^\circ$ = mid, $90^\circ$ = straight up).
  • fire(power): Ignites the propellant with muzzle power ($10$ to $100\%$).
  • wait(seconds): Simulates the physics while the shell arcs across the sky.
artillery_game(1)
aim(45)

fire(72)

wait(3.5)
Move the mouse over a dotted box for more information.

  • Live Ballistics HUD: Displays the Current Barrel Angle, Firing Power, Wind Vector, and Horizontal Range to Target.
  • Trajectory Guide: The dotted cyan guide line projects the theoretical flight path and terrain impact point.
  • Terrain Cratering: Shell impacts physically deform the terrain, blasting craters into mountains and skylines!
  • Interactive Mouse Aiming: You can also aim the barrel manually by dragging the mouse near the turret!

Now you try. Can you hit the target in Stage #1, or try artillery_game(2) to loft a shell onto the cliff fortress?

Type your code here:


See your results here: