3D Engine v2.1 (Z Buffer)
Up arrow / W Forwards
Down arrow / S Backwards
Left arrow / A Turn left (anti-clockwise)
Right arrow / D Turn right (clockwise)
M Show Map
This is the second version of my 3D engine :D
Asides from being loads faster, it now features:
- Line smoothing (at the tops and bottoms of walls)
- Layered textures
- Look up and down (via the mouse)
- A much better internal framework for creating objects and textures
How it works:
Each shape is stored as a series of walls.
Each wall has a start point, end point and an angle.
First, we calculate the angle from the camera to the start and end points of the wall.
Then, we calculate the distance from the camera to the start and end points of the wall.
We can then use this information to calculate the distances between the camera and all the points along the wall (using the sine rule).
The distances are stored in a list (the z buffer) and only the shortest distances ever gets stored for each angle.
Each distance within the field of view is then scaled, colored and drawn on the screen.
Thanks to @WO997 for loads of useful advice!