Lode Vandevenne writes graphics programming tutorials and personal projects, including raycasting, demoscene effects, LodePNG, and a logic simulator.
Commenters call his old-school tutorials great, and HN links them for the raycasting and fire effect pages, which they find simple and rewarding to build.
I wrote a similar code a few years ago, although it also supported textures (including ground and skybox, unlike the original Wolfenstein). I don't know if it'll be more to your taste but there are afew comments: https://bitbucket.org/simias/wolf/src/873cad46f3c8281e7d94293b21af3c72e831d860/wolf.c?at=default&fileviewer=file-view-default the magic happens in wolf_horizontal_intersect. Note that I use fixed point which obfuscates the arithmetic a bit (I was targeting an embedded platform without hard float at the time).
It looks like this while running: https://svkt.org/~simias/misc/wolf-floor.png
That being said if you're interested in writing something like that I recommend that you use any basic tutorial on raycasting and try implementing it "from scratch" yourself, it's pretty simple and quite fun IMO. IIRC I used this one: http://lodev.org/cgtutor/raycasting.html
this is a pretty faithful reproduction. I like it! a lot of solid pointers to great algorithms in here.
- perlin noise: https://en.wikipedia.org/wiki/Perlin_noise for generating terrain bumps
- flood fill for painting terrain on top of noise : http://lodev.org/cgtutor/floodfill.html#Scanline_Floodfill_Algorithm_With_Stack
- convolutions with webgl shaders https://github.com/phoboslab/WebGLImageFilter
- dilation filter
- "closing" in image processing https://en.wikipedia.org/wiki/Closing_(morphology)
- deciding in the hqx algorithm for anti aliasing https://en.wikipedia.org/wiki/Hqx
- texturing
- halton sequences for even distribution of worms https://en.wikipedia.org/wiki/Halton_sequence
- sine wave for water
all done in the browser.
github repo at https://github.com/juliango202/TerrainVer
When I was in middle school, I had dabbled in coding but only knew how to make simple CLI applications that ran on the terminal. Then one day I stumbled on Lode's Computer Graphics Tutorial and I finally had easy to understand examples of how to open a window and draw some graphics on the screen. That led me to recreating a bunch of retro games (Pacman, Snake, Space Invaders, etc) that would not have been possible on the terminal.
I credit this site for really kickstarting my career in software development from a somewhat early age. Big shout out and thank you to Lode. Back then, I practically memorized all the pages and examples in https://lodev.org/cgtutor/, even if some of the math went right over my head at the time
It's a neat trick of projection, and really easy to hack on and extend yourself once you know the trick. Using your map of the space, cast a ray from the camera position through every column of the display rectangle; using the distance the ray travelled before intersecting the wall, you can calculate the apparent height of the wall seen in that column of the display; so, in that column, draw the wall that high. You can get fancier with textures for the walls, varying the floor height, walls that can appear and disappear (i.e. "doors"), and so on.
Better than my 10-second explanation: https://lodev.org/cgtutor/raycasting.html
Nice writeup! Building raycasting engines is fun and rewarding. You can get a lot of visual impact with very small and easy to understand code. I took a stab at it and ended up adding portals which I thought was really fun (https://github.com/gh123man/Portal-Raycaster).
I've been thinking about re-writing my raycasting engine in Rust but never really found the time - glad to see someone has done it and documented it so well!
If anyone else is interested in raycasting this page is also worth a read: https://lodev.org/cgtutor/raycasting.html
As someone currently embroiled in a project to motivate people to explore classic videogame development techniques- this is super interesting.
I'm not sure how I feel about Pygame/Pygame Zero, though. It feels a little detached from classic C techniques and doesn't present the technical challenges of original hardware. On the up side, it's far more accessible to beginners.
I really enjoyed working through, for example, this Wolfenstein 3D-style raycasting tutorial- https://lodev.org/cgtutor/raycasting.html