13 ms·
Rustenstein 3D: Game programming like it's 1992
- filereaper 5y agoI'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 https://news.ycombinator.com/item?id=24959157 Excellent article btw.
- adamrezich 5y agothis 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
- AnIdiotOnTheNet 5y agoFast 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.
- tyrells 5y agoSaw this recently too: https://mattiasgustavsson.itch.io/dos-like 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."
- gh123man 5y agoRay 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 https://github.com/gh123man/Portal-Raycaster 1. https://blog.sb1.io/gateescape/ https://blog.sb1.io/gateescape/
- martincmartin 5y ago> a very high "effort to reward" ratio, Sorry to be pedantic, but I think you mean the opposite? Big reward for modest effort?
- nine_k 5y agoIt may be seen as a transmission ratio: reward = ratio * effort. Then the ratio is indeed high!
- spullara 5y agoYou mention GCd languages being a bad choice for games in your README. But these days Java has GCs that have < 1ms pauses. I wonder if it is still true? https://kstefanj.github.io/2021/11/24/gc-progress-8-17.html https://kstefanj.github.io/2021/11/24/gc-progress-8-17.html
- avereveard 5y agoIdk why people are so worried about gc in general, just keep an object pool around and byte arrays if strings are immutable and never see a GC pause. Sure it'll look a lot like c, but that's besides the point.
- hedora 5y agoAt that point, you're not benefiting from the GC'ed language. Just use C/C++/Rust/etc, and you'll end up with something faster and more reliable for a small fraction of the effort.
- Too 5y agoObject pools don’t turn off by one errors into complete remote code execution exploits.
- AnIdiotOnTheNet 5y ago
- dormando 5y agoLooks like the engine is missing the fish-eye correction in the ray-cast calc. I love writing these engines for fun :)
- dahart 5y agoFish eye is a feature! ;) https://strlen.com/gfxengine/fisheyequake/ 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.
- a_e_k 5y agoThat's exactly what it's doing: let rayAngle = player.angle - player.fieldOfView / 2; for(let rayCount = 0; rayCount < screen.width; rayCount++) { // ... SNIP ... // the ray moves at constant increments let rayCos = Math.cos(degreeToRadians(rayAngle)) / precision; let raySin = Math.sin(degreeToRadians(rayAngle)) / precision; // ... SNIP ... // increment the angle for the next ray rayAngle += incrementAngle; } It's also using Euclidean distance rather than planar distance for the apparent wall height calculation.
- hrydgard 5y agoIf 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.
- dormando 5y agoThe venerable lodev tutorial uses this method, which I also used for most of my engines. I learned an interesting tidbit while comparing the two methods though: The old-school original methods used pretty small cos/sin/atan lookup tables to do the ray and then the correction calc. Using the linear method you end up with a couple divisions per ray that aren't there in the lookup method. Divisions were (and are, depending on the platform) pretty slow. Linear method still works with lookup tables but they're relatively huge. Also IIRC With the linear method door-indents need a workaround.
- pjmlp 5y agoI guess using Rust kind of fits the boots of Turbo Pascal for 1992.
- 10x-dev 5y agoTurbo Pascal is small, fast and has a clean syntax. Rust fits in none of those shoes (yet, I suppose).
- stjohnswarts 5y agoRust isn't fast? O_O . The others I can see...
- philipkglass 5y agoTurbo Pascal was famous for compiling projects quickly. The current rustc compiler is not. The output of the rustc compiler can be better optimized for run time than the output of Turbo Pascal, though.
- pjmlp 5y agoYes, the compilation speed wasn't something I had on mind when I made the remark, maybe I should have abstained to play clever. Anyway maybe when Cranelift gets more mature.
- pjmlp 5y agoIt fits on having a var : type syntax, naturally it isn't Turbo Pascal 6.0 with the Turbo Vision IDE, given 1992. I still hope that alternative backends like Cranelift will fix the compilation speed.
- jacquesm 5y agoIn fact Turbo Pascal (and later TurboC) was so fast that initially I thought there was something wrong with the compiler, that's how quick it compiled a program. CTRL-F9 and off to the races.
- atum47 5y agoI'm a sucker for wolf 3d technology... Great job!!!
- lkxijlewlf 5y agoIs there anything like this for Voxels (what's used in Roblox, MineCraft,etc)?
- ziggus 5y agoIsn't Minecraft a plain old polygon renderer?
- jacquesm 5y agoVery large textured voxels!
- dejv 5y agoThere are few articles on 0fps blog: https://0fps.net/2012/01/14/an-analysis-of-minecraft-like-engines/ https://0fps.net/2012/01/14/an-analysis-of-minecraft-like-en... Readable implementation (in C) is this: https://github.com/fogleman/Craft https://github.com/fogleman/Craft
- lopuhin 5y agoThere is a very simple voxel terrian renderer: https://github.com/s-macke/VoxelSpace https://github.com/s-macke/VoxelSpace
- ahuth 5y agoAdding my own raycasting implementation, in... what else... React/JavaScript -> https://huth.me/raycast/ https://huth.me/raycast/
- Koshkin 5y agoNeed a map editor now :)
- markus_zhang 5y agoI'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 5y agoBonus 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.
- hnthrowaway0315 5y agoYeah definitely! Is there any modern tools that can 1) run on native platform and 2) significantly improve dev experience? I guess the guys who developed Nox Archaist used some modern tools, and on DOS we might have something new because of a large retro community. The more I think about it, the more I believe if someone can pull this off, although many skills learnt are useless in modern programming (like 6502 asm or 80286 asm or whatever tricks to get the games run smoothly on retro platforms), but the amount of effort definitely would pay off. I don't think one needs to walk the full Carmack road. I think whoever goes from Shadowforge to Quake is impressive enough. Plus one does not need to implement all these games, many of them share similar engines. (Bad formatting...) June 22, 1996 Quake id Software GT Interactive Programming May 31, 1996 Final Doom id Software GT Interactive Programming October 30, 1995 Hexen: Beyond Heretic Raven Software id Software 3D engine December 23, 1994 Heretic Raven Software id Software Engine programmer September 30, 1994 Doom II: Hell on Earth id Software GT Interactive Programming December 10, 1993 Doom id Software id Software Programming 1993 Shadowcaster Raven Software Origin Systems 3D engine September 18, 1992 Spear of Destiny id Software FormGen Software engineer May 5, 1992 Wolfenstein 3D id Software Apogee Software Programming 1991 Catacomb 3-D id Software Softdisk Programming 1991 Commander Keen in Aliens Ate My Babysitter! id Software FormGen Programming December 15, 1991 Commander Keen in Goodbye, Galaxy! id Software Apogee Software Programming 1991 Commander Keen in Keen Dreams id Software Softdisk Programming 1991 Shadow Knights id Software Softdisk Design/programming 1991 Rescue Rover 2 id Software Softdisk Programmer 1991 Rescue Rover id Software Softdisk Programmer 1991 Hovertank 3D id Software Softdisk Programming 1991 Dangerous Dave in the Haunted Mansion id Software Softdisk Programming 1991 Dark Designs III: Retribution Softdisk Softdisk Programmer/designer December 14, 1990 Commander Keen in Invasion of the Vorticons id Software Apogee Software Programming 1990 Slordax: The Unknown Enemy Softdisk Softdisk Programming 1990 Catacomb II Softdisk Softdisk Developer 1990 Catacomb Softdisk Softdisk Programmer 1990 Dark Designs II: Closing the Gate Softdisk Softdisk Programmer/designer 1990 Dark Designs: Grelminar's Staff John Carmack Softdisk Developer 1990 Tennis John Carmack Softdisk Developer 1990 Wraith: The Devil's Demise John Carmack Nite Owl Productions Developer 1989 Shadowforge John Carmack Nite Owl Productions Developer
- fabiensanglard 5y agoThat 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 5y agoThanks 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!
- fabiensanglard 5y agoAny plans for a full DOOM (not render-only)?
- facundo_olano 5y agoWe haven't got to reading the Doom book yet, maybe once we do! Although for now we're likely going to focus on developing this one some more, if we manage to get the time.
- nyanpasu64 5y agoI wonder how practical it would be to create a Wolfenstein 2D with the same level design, but played in top-down view.
- syngrog66 5y agoheresy! cough Castle Wolfenstein, by Silas Warner for MUSE kids: get off my lawn
- dasKrokodil 5y agoYeah, so many comments here talking about the 'original' Wolfenstein while meaning Wolfenstein 3D... This is where it all started: https://www.youtube.com/watch?v=8fgok9eHqO8 https://www.youtube.com/watch?v=8fgok9eHqO8
- syngrog66 5y agoin color? luxury! we had black and white and we were grateful for it! kids: get off my lawn the grenade explosion was the most satisfying ever. "Take that Nazi scum!" the 1st Rogue-like I ever made was something I called WolfenHack. my personal cross between Castle Wolfenstein and NetHack. I later genericized my engine and built a zombie apocalypse on top of it.
- facundo_olano 5y agoI 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)
- anthk 5y agoNot a roguelike, but hunt/huntd is like wolf2d.
- kibwen 5y agoBehold, Wolfenstein 1D! https://www.youtube.com/watch?v=QSvECzuaYn0 https://www.youtube.com/watch?v=QSvECzuaYn0
- abrookewood 5y ago"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.
- dannyincolor 5y agoA direct link to the source code, for those interested: https://github.com/AdRoll/rustenstein https://github.com/AdRoll/rustenstein
- philderbeast 5y agoits a shame they included the original shareware resource files in there without any mention that they are NOT covered by the MIT licence that the repository is under.
- superfamicom 5y agoThere was a more recent Kickstarter that got my interest in the DOS style games restarted: https://www.kickstarter.com/projects/eniko/coding-history-3d-from-mode7-to-doom https://www.kickstarter.com/projects/eniko/coding-history-3d...
- markus_zhang 5y agoI'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.
- flumpcakes 5y agoThis sounds very interesting! I don't anything more productive to add, other than I would love to read/see/watch/play any output that a project like this had.
- 5- 5y agosee also: a series of posts (with accompanying code) on rewriting the doom engine from scratch: https://github.com/amroibrahim/DIYDoom https://github.com/amroibrahim/DIYDoom
- alkonaut 5y agoIs 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 5y agoThe 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 5y agoYou could look at one of the ports of Wolfenstein. Perhaps the SNES version? ;-)
- deleted 5y ago[deleted]