I’ve always been fascinated with games that try to create the illusion of 3D using 2D drawing techniques. A while back I decided to challenge myself to finally figure out how raycasting works and attempt to build my own basic engine that is comparable in function to the engines found in games like Wolfenstein 3D and Ultima Underworld.
References and Samples
After doing some research I found that the principles behind raycasting are actually very simple. I’m not going to go into great detail about how raycasting works but it you want to know the specifics then I recommend checking out the articles below. I used these for reference and inspiration in my design.
It’s fun to think that since raycasting utilizes basic math and trigonometry, one can created even on some of the most constrained systems. A really neat example of this that I found is the raycaster below that someone made on a Gamebuino (an Arduino based handheld).
And here’s another one that someone created for the NES.
Go to the Result tab and click the Run button see it in action.
And this is a fiddle of the same engine in CoffeeScript.
At this point you can see it’s basically just a rotating tech demo but I’ve got the framework established. These are some of the features I’m hoping to incorporate in the future.
- Keyboard controls
- Textured walls
- Variable height walls
Additional at some point I’m hoping to get my hands on an Arduboy once they come out and hopefully port the engine to that platform.