top | item 30182565

Rustenstein 3D: Game programming like it's 1992

351 points| facundo_olano | 4 years ago |tech.nextroll.com

113 comments

order
[+] gh123man|4 years ago|reply
Ray casting is close to my heart as it's easy to understand and has a very high "effort to reward" ratio, especially to someone who is new to graphics programming. I built a game + engine around ray casting portals [1] (think the game Portal). It was a lot of fun trying to figure out how to bounce rays around a scene and intersect with different objects in the environment and immensely satisfying to have built the whole engine from the ground up. Though I'd probably not do it again. Your top-down ray debug view is very similar to one I came up with!

Some of the interesting bits of the engine are open source: https://github.com/gh123man/Portal-Raycaster

1. https://blog.sb1.io/gateescape/

[+] martincmartin|4 years ago|reply
> a very high "effort to reward" ratio,

Sorry to be pedantic, but I think you mean the opposite? Big reward for modest effort?

[+] fabiensanglard|4 years ago|reply
That looks great. I actually wanted to do a port of an id game in Rust for the longest time but never managed to find spare cycles.

I would add to the list of feature to tackle next:

- Convert from 320x200 aspect ratio to 320x240 aspect ratio. You can do that by converting from 320x200 to 1600x1200. This is easily done with x5/x6 which give you the same aspect ratio as 320x240 and you get no pixel selection artifacts.

[+] facundo_olano|4 years ago|reply
Thanks for the suggestion, and for your book and your blog posts, by the way, they are the main reason we thought about tackling this project!
[+] markus_zhang|4 years ago|reply
I'm wondering if anyone develops a spinoff exactly as back in 1992.

You know, it would be interesting to follow the Carmack's route: start from Apple ][ programming for a couple of Ultima and Wizardry spinoffs, port them to PC. Then move to 80286 to make a scrolling engine for a double trilogy, and move up to 80386 to make a Wolfie clone, and continue from there. The point is to use real world machines or emulated env for development. One can probably learn a LOT programming by that way, although much if it is irrelevant in modern gamedev...

[+] aninteger|4 years ago|reply
Bonus points for using the same tooling and languages from then too. 6502 assembly, then a bit of 16 bit x86 assembly, and finally some C with Borland's 1992 tooling.
[+] nine_k|4 years ago|reply
This would be a feat.

But many more people look for the fun. The good bits without the pains of ancient tooling, lacking debuggers and graphics tools, etc.

[+] jacquesm|4 years ago|reply
A simple raytracer is also a good step in that list.
[+] dormando|4 years ago|reply
Looks like the engine is missing the fish-eye correction in the ray-cast calc. I love writing these engines for fun :)
[+] dahart|4 years ago|reply
Fish eye is a feature! ;) https://strlen.com/gfxengine/fisheyequake/

I noticed it in the examples too, I’m speculating wildly that the ray cast is even angular steps rather than pinhole projection. Totally reasonable to not correct it, IMO, I’ve long thought we should have more non-linear cameras in games.

[+] hrydgard|4 years ago|reply
If you generate the rays the linear way instead, you don't even need any correction.

Generate two points which represent the left and right edges of the screen - you'd put them in at say 45 degrees left and right of the forward vector of the player. Then to generate the direction vector for each column of the screen, just interpolate linearly between those two points, and find the vector from the player to that intermediate point.

[+] alkonaut|4 years ago|reply
Is there a limit when looking at retro games when the retro-ness becomes a burden rather than "old games is simpler"? Obviously if you move too far back in history you end up with basically game specific hardware, long-dead assembler code. In the original wolfenstein it seems there is a bunch of code relating to things that manage weirdness that we no longer care about (paging, legacy graphics handling) which obscure the actual game.

Was there a "peak" in simplicity when games were at their simplest for a reader from 2022? That is, they are modern enough to not be obscured by historical weirdness yet still simple enough to be approachable? Perhaps Doom is simpler to understand than Wolfenstein for this reason?

[+] laumars|4 years ago|reply
The trick isn’t to look at the complete game code which will always have platform specific code but rather look at the tricks used by the game engines that are conceptual. Or in other words, look at the design rather than the implementation.

This is true even for modern games, because you might implement something differently for a mobile game than you might for a high end PC.

[+] ant6n|4 years ago|reply
You could look at one of the ports of Wolfenstein. Perhaps the SNES version? ;-)
[+] tyrells|4 years ago|reply
Saw this recently too: https://mattiasgustavsson.itch.io/dos-like

"dos-like is a programming library/framework, kind of like a tiny game engine, for writing games and programs with a similar feel to MS-DOS productions from the early 90s."

[+] superfamicom|4 years ago|reply
There was a more recent Kickstarter that got my interest in the DOS style games restarted: https://www.kickstarter.com/projects/eniko/coding-history-3d...
[+] markus_zhang|4 years ago|reply
I'm thinking exactly about the same thing, but a broader one called the Carmack's road, from Shadowforge on Apple ][ to maybe Quake I, all developed on the original platforms (emulator). Of course not as a tutorial series but as a learning path for myself for the next maybe 5-8 years.
[+] nyanpasu64|4 years ago|reply
I wonder how practical it would be to create a Wolfenstein 2D with the same level design, but played in top-down view.
[+] facundo_olano|4 years ago|reply
I had the same idea while working in this project. Either play directly from the map view (the prototype sort of already does this) or even use a rogue like ascii interface (which, yes, would probably be similar to the Silas Warner game)
[+] syngrog66|4 years ago|reply
heresy!

cough

Castle Wolfenstein, by Silas Warner for MUSE

kids: get off my lawn

[+] abrookewood|4 years ago|reply
"a “Carmack” compression, which is John Carmack’s variant of the LZ (Lempel-Ziv) method. According to the Black Book, without much access to the literature, Carmack would “invent” an algorithm to later find out that someone else had done it before.". Wow, he really is amazing.
[+] filereaper|4 years ago|reply
I'm guessing the infamous inverse square root algorithm was used originally for ray-casting described in the article?

Fast Inverse Square Root: https://news.ycombinator.com/item?id=24959157

Excellent article btw.

[+] AnIdiotOnTheNet|4 years ago|reply
Fast inverse square root was part of the lighting calculations in Quake III IIRC. Nothing so obtuse is required for the simple ray-casting demonstrated here.
[+] adamrezich|4 years ago|reply
this project is a pseudo-remake of Wolfenstein 3-D; Fast Inverse Square Root as we know it wasn't in an id game until much later with Quake III Arena
[+] pjmlp|4 years ago|reply
I guess using Rust kind of fits the boots of Turbo Pascal for 1992.
[+] 10x-dev|4 years ago|reply
Turbo Pascal is small, fast and has a clean syntax. Rust fits in none of those shoes (yet, I suppose).
[+] lkxijlewlf|4 years ago|reply
Is there anything like this for Voxels (what's used in Roblox, MineCraft,etc)?
[+] ziggus|4 years ago|reply
Isn't Minecraft a plain old polygon renderer?
[+] atum47|4 years ago|reply
I'm a sucker for wolf 3d technology... Great job!!!