A Wolfenstein 3D–style raycasting engine that renders a first-person 3D view in ASCII, live, in terminal. It does not use any graphics library.
The engine casts one ray per terminal column using a DDA (Digital Differential Analysis) grid-stepping algorithm — the same core technique used in classic raycasters — to find how far each ray travels before hitting a wall. Distance is then mapped to:
- Wall height: closer walls fill more of the screen vertically
- Shading: a density ramp (
█▓▒░.:) picks a denser character for closer surfaces and a lighter one for farther ones, with a subtle dimming applied to one wall orientation so vertical and horizontal surfaces read as visually distinct — a cheap but effective stand-in for directional lighting
A minimap in the corner shows the full map layout and the player's live position, and an on-screen HUD reports position, facing angle, and current FPS.
| Key | Action |
|---|---|
W / S |
Move forward / backward |
A / D |
Rotate left / right |
Q / E |
Strafe left / right |
Esc / Ctrl-C |
Quit |
python asciiraycast.py- Unix/macOS: uses the built-in
cursesmodule — no install needed. - Windows: run
pip install windows-cursesfirst, then run normally.
The engine adapts to your terminal size at runtime (it'll ask you to resize if the window is too small), and is capped at 60 FPS.
Raycasting is one of the cleanest examples of getting real 3D-feeling perspective out of very cheap 2D math, and doing it in a terminal — with no framebuffer, no textures, just character density as a proxy for depth — makes you work with exactly what information a "3D view" actually needs: distance per column, and nothing else.