Raycasting is what the original Wolfenstein 3D and Doom used. So itâs well suited for JavaScript. Though this looks like the Wolf3D generation, not Doom.
More of a first person stabber, in fact.
Doom used binary space partitioning - a different beast. Blake Stone used raycasting, IIRC.
Ok, I hate javascript.
But this is niiiiiice!
I wish more people could code as simply and straightforward as this.
Theyâre both raycasting - just throwing a light ray to see where it hits. But Wolfenstein does it with a simple grid layout. Doom uses BSP to divide the casting space up efficiently so you can get away from the grid.
See here for some details: http://bespin.org/~qz/pc-gpe/doom.txt
Wow, cool. I was half expecting each line to be 100 bajillion characters long, but that code is really clean, simple, and easy to read through and understand.
Yes, I am aspiring to this level. Heâs awesome.
Ok, I hate javascript.
Just out of curiosity, what do you prefer instead?
I wanna see it combined with this:
http://dcc.fceia.unr.edu.ar/~rbaravalle/fractales/brownGL.html
insane in the membrane.
Oh geez, thatâs right. I used to know all that stuff.
I need to go dust off my Doom & Doom II mods.
I canât get the demo to have a decent framerate in Firefox⌠It only advances through the frames when my mouse is moving, and itâs eating a vast amount of CPU.
âStop using Firefox then,â said every frustratingly myopic coder ever.
Turns out it works in chrome.
Just FYI, if your last experience with Javascript was horrible spaghettis of jQuery written by âweb designersâ six years ago, come back and look again. JS frameworks, standards and, most importantly, expectations of clean code, have moved on a LOT since then.
Flamebait aside, but I use flex and actionscript, and java. Actionscript 3 is ecmascript 2, which is what javascript was supposed to update to. Its much more like java and has strict typing, and real classes, which js doesnât and though you can do some hacky things with that, it can quickly turn into completely unmanageable code. AS also has native E4X xml objects which is crazy easy and powerful, js can do xml, but itâs not as good, and thatâs why most js uses JSON for its ajax data. (the x is supposed to be for xml
What I hate most about js is the overuse of inline functions⌠within inline functions, within inline functions⌠Thatâs just crazy. And if you miss 1 comma everything goes boom.
This code, however, is a wonderful example of clean code that can be done in JS. Not hacky, tricky stuff that some were expecting.
Itâs not per se elegant, but this is what I would call âcrystallizingâ your code, which is refining it down to exactly and only what it needs to be. No extra variables or functions that you may need later, or might be cool at some point.
Every single thing here is used and nothing wasted, no extraneous junk to muck things up. And thatâs why they can keep it short, and explain how the whole thing works beautifully.
And now is the time that other coders will grab it and muck it all up
What is your definition of elegant? Itâs OK to pay something an unreserved compliment. That doesnât make you weak.
âPleasingly ingenious and simpleâ is what I go by and this fits that definition pretty darn well.
Flamebait aside
Iâm glad you put that aside, because that wasnât my intention. I just enjoy hearing about what people like to go along with what they donât like.