[WIP] Raycaster


(John D. Corrado) #1

Hi, I am new to the community and have been hard at work on a raycaster project for the Arduboy. I am using the Fixed Points library and currently have all of the following working.

Movement
Move Forward
Move Backward
Turn Left
Turn Right
Strafe Left
Strafe Right

Interaction
Wall and door collision with a nice sliding effect
Doors that open when you stand in front of them

Here is a preview GIF.

ArduboyRecording

I hope you enjoy this preview as I am very proud of the initial work I have done.


(Boti Kis) #2

It is always so fascinating to see what people can do on this hardware. I have a very limited understanding of how this may work and i have deepest respects to all of you people who makes these 3D games :smiley: Keep going!


(Simon) #3

That is awesome … what are you planning on doing with it? Is there much progmem or RAM left for a game?


(Pharap) #4

This is exactly the sort of thing I was hoping people would use FixedPoints for.


(Simon) #5

Yep … it really shows off the power of the library. Think we can mash this into Dark & Under?


(Stephane C) #6

If you could that could add some battle tactic to the game for sure, knowing when to back off and then hit a monster. And would make the game look even cooler!


(John D. Corrado) #7

I don’t currently have any idea of what I am going to use this for, so I would be willing to share the code after some refactoring or collaborate with others. The current implementation does use a little over half the progmem and a good bit of the RAM, but I am sure that can be figured out.


(Simon) #8

Right … so Dark and Under uses 100% of both, almost. Sounds like a match made in heaven :slight_smile:


(Pharap) #9

To be honest, I don’t think D&U’s turn-based mechanics would properly take advantage of a raycasting engine.

I think it would be best suited to either a traditional doom-like FPS or an FPS-RPG game like Barony or Eldtritch (but keep the map one-block tall).

Both could incorporate some of the techniques D&U used for managing the map and enemies,
but the turn based elements and the HUD would be gone (in favour of a more minimalistic HUD).


(John D. Corrado) #10

It would probably be better used for a new project in that case.


#11

Does anyone have plans for a game using this? It would look great!


(Simon) #12

I would love to … I would like to make a FPS but @igvina and @luxregina may be making the definitive version in their Doom game. Maybe a maze game where you race the clock to complete tasks or simply make it through?


#13

That sounds like a great idea! I would make it, but I know exactly nothing about coding on the arduboy. I will read up and try, though.


(Simon) #14

One of the issues I can see is having other (fixed and moving) items in the environment that would need to be scaled as you approach them. Obviously this is memory intensive (if using multiple images) or CPU intensive (if you plan to resize them dynamically with generally average results).

Without seeing the code, I wonder how other fixed items can be included in the rendering algorithm. Will you have to let the engine draw the environment then you will have to calculate whether you need to render the item (it may be hidden by a wall) and then, based on its distance from the player) at what size.

I can see memory being a big issue here !


(Pharap) #15

I think if sprites only scaled down then it wouldn’t be too bad.
You would need a custom sprite drawing function, but basically you’d just have to use UV-like coordinates and maybe some lerping.

Now obviously with floats that would be difficult, but with fixed points…

If anything, I think speed would be the issue in this case.

Calculating whether you can see an item or not is probably easier than expected.
I’m pretty sure it could be merged with the ray pass.


(Simon) #16

Do tell? Do you know of such a library??

I would hope so, but not sure how flexible this engine might be.


(Pharap) #17

Which reminds me, I’m still waiting for it to be added to the quickstart guide:

Though we have a new quickstart guide now anyway, so I guess it’s Kevin I’d have to talk to.

Until we see the code, I’m assuming it’s just a port of the code from Lode Vandevenne’s semi-famous tutorial.

https://lodev.org/cgtutor/raycasting.html

That’s usually what most raycasting implementations are based on because it’s probably the most comprehensive guide on the internet.


(Simon) #18

I hadn’t seen this reference before - I haven’t read the entire internet yet! - but it looks very comprehensive.


(John D. Corrado) #19

I have read both Lode Vandevenne’s tutorals and F. Permadi’s tutoral in the past. They are both wonderful sources of information on raycasters. Fabien Sanglard’s recent book on Wolfenstein 3D is a great technical book as well. I highly recommend it. My implementation is original with some pieces, such as the collision logic, that I used from another implementation. I tried to create a pretty straightforward version that includes the standard stuff and some original ideas I came up with. I will definitely release the source code soon.


(Scott) #20

Well, being a moderator, you could have done it yourself :slightly_smiling_face:. However, I’ve now done it.