Playing with raycasting. By default: top down flashlight simulator. Hit Z to go 3D instead!
X will loop through FOV settings, toggle between top down and 3D to visualise what's going on.
UPDATE: Now with zooming effect
Yeah, there's a lot of very impressive ones in progress on the Discord as well. I'm sharing this because it helped me make sense of how it works, I had an idea for a flashlight mechanic and someone suggested using raycasting to draw the beam. Took me forever to get the maths right, but I was chuffed when it worked.
Only much later did I realise I kind of had a 3D engine already; instead of drawing beams going out from a point of length X, I just had to draw vertical lines on the screen for each beam, with a length inversely proportional to the length of the beam. Took literally 7 lines of code to go from flashlight to 3D! :p
[Please log in to post a comment]