A cannon at one end, an ammunition dump somewhere down range, and a parabola between them. Set the elevation and the muzzle velocity and try to land a shot on the target.
What Cannon does
It is a game, but the trajectory is honest. The shot follows
x = x₀ + v cos(a) t
y = y₀ + v sin(a) t - g t²
which is projectile motion with no drag. Doubling the velocity quadruples the range, forty-five degrees carries furthest, and every elevation below that has a matching one above it that lands in the same place. All of that falls out of the maths rather than being faked.
How to use it
- Load the routine with
APPLOAD, or put it on your support file search path. - Type
CANNON. - Give an elevation angle and a muzzle velocity.
- Watch where it lands, and adjust.
How it works
The whole game is drawn as temporary vectors. Nothing is added to the drawing at all, the view is restored, and every system variable goes back. You can play it in the middle of real work and lose nothing.
That is worth saying because the routine this was rebuilt from did the opposite: it set LIMITS to a hard-coded -600,-300 to 1800,1080, turned LIMCHECK off, zoomed to those limits, and set CMDECHO, BLIPMODE and HIGHLIGHT without ever putting any of them back. Its own last instruction was to print “Please QUIT this Drawing” — an honest admission, but not a fix.
The random target. 1980s AutoLISP had no random number function, so the original carried a table of a hundred hand-written decimals. The table is kept — it is perfectly good — but the starting point is taken from the clock, so the targets differ from game to game instead of repeating the same hundred in the same order.
Notes and limits
- Nothing is added to the drawing and every system variable is restored, so it is safe to run in a live file.
- No drag. The trajectory is a true parabola, which is why 45° is optimal — real artillery is not so tidy.
- Temporary vectors clear on the next redraw.
- There is no undo group, because there is nothing to undo.
Download and details
| Name | Cannon — an artillery game with an honest trajectory |
| Download | Cannon.lsp — 11.2 KB, plain AutoLISP source. Downloads directly; no zip to unpack. |
| Type | AutoCAD AutoLISP routine |
| Command | CANNON |
| Requires | nothing beyond a CAD platform with AutoLISP. |
| Source size | 11.2 KB, 275 lines |
| Error handling | Yes — a *error* handler restores every system variable it changed, on cancel as well as on error. |
| Undo | Not needed — this routine only reads the drawing and changes nothing. |
| Compatibility | AutoCAD (any release with AutoLISP), BricsCAD, ZWCAD, GstarCAD, ProgeCAD and other IntelliCAD-based platforms. AutoCAD LT needs a LISP enabler. No .NET, no ObjectARX, no installer. |
| Author | YZ, August 2026 |
| Licence | Free to use, supplied “as is” with no warranty. |
References
- TOWERHANOI LISP — the other one that draws itself and cleans up after
- Drafting funnies — the rest of the site’s lighter corner
- More free AutoLISP routines on this site
- Wisey’s Steel Shapes — free structural steel section drawing program