Thursday, August 4, 2016

Raycasting woes

What I'm working on now is a raycasting engine, like was used back in the days of Wolfenstein 3D. It's not a complicated technique, really, but it's a little fussy, and I just couldn't get my last attempt to quite work right.

My original attempt was based partly on trying to convert A first-person engine in 265 lines from javascript to haxe, with this actionscript-based raycaster as a second opinion. I never quite got the math to work right, and it was running painfully slowly anyway. I might have been able to work it out if I'd been more diligent about putting debugging tools into my code, but I instead went the simpler route of ripping everything out and starting over!


This time, I'm using a technique from Lode's Computer Graphics Tutorial. Instead of doing a bunch of trigonometry for every column to be rendered like the previous technique I was trying to use, this technique uses vectors, basically just calculating once per frame instead of once per pixel-column. It turned out to get a much better framerate even without doing any optimizations, and as an added bonus:

It actually works!

Next up is to draw the ceiling and the floor, instead of just using solid colors.

 I've tossed the code up on bitbucket, if you want to poke around at it.

3 comments:

  1. Heyho :). I'm trying to learn AS3 + Flex SDK + Flixel to jump a little bit more into the practice of game developing. You're helping me a lot. I never did a project with Flash Develop (or something with Flash in general), so i'm starting totally from scratch as you did time ago. Hope to hear from you somehow at some time. I will now read through this whole blog and try to learn as much from you as possible ^__^.

    ReplyDelete
  2. It's me again. Dunno why i am mentioned as unknown but hey, pretty sure it will take some time until you answer. Changed to Haxeflixel atm like you said everyone else did :D. And it's a huge less pain in the ass. I have read so fucking much the past 10 days ouh my gosh... and today, i thought about visiting Kongregate again for some good ol' flash games n stuff, just for a quick play, i had an hour to surpass.

    And dude, i mean it as i say.. I took the first game i saw somewhere, and it was Project Jumper. Played and played and played, then i read the description and that blew my mind....

    btw. for a flash game in 2011 by a guy with at that time literally no professional experience, that game felt soo good... I've played it an hour or so, until there were only one coin left, and than i ran into a bullet by mistake and ragequited...

    but dude AWSOME Game / Prototype

    ReplyDelete
  3. what came to my mind is that I might just message you on Kongregate <_<...

    will do that tomorrow, but today there is no time left. And by the way, sorry for the stalking, i'm just a huge fan of indie game development

    ReplyDelete