Raycaster 1 -- By anarkavre


Author :  anarkavre

Hi, I have been working on a Raycaster project for the Arduboy and decided to port it to the Gamebuino META. It currently has the following features.


Move Forward

Move Backward

Turn Left

Turn Right

Strafe Left

Strafe Right


Wall and door collision with a nice sliding effect

Doors that open when you stand in front of them

This version includes texture mapped walls, doors, ceiling, and floor. The Wolfenstein 3D textures are placeholders I used for testing.

I hope you enjoy this preview.

See more
Author :  bfx

Very cool!!!  Thanks for sharing.

Maybe worth mentioning that you need the FixedPoints library to compile (Sketch>Include Library>Manage Libraries then search for FixedPoints).

Author :  jicehel

Thanks fo the share and i hope you'll continue it to make a complete game.

If you want compare with some other raycasting codes, you can have a look on:

Raycaster by Arnakavre (https://gamebuino.com/fr/creations/raycaster)

Advanced Raycasting by drummyfish (https://gamebuino.com/fr/creations/advanced-raycasting)

Author :  jicehel

Code is fine and works fine but it's not easy to understand as there is alot of maths and not alot comments. Could you had some in your code ?

As it's a preview and as you wrote: "It currently has the following features" , it's mean that you'll add some more, know you already that you'll add ? possibility to have ennemies and a hit function with some parameters as range, shoot angle, full_damages_points ?

Author :  sentinel87

Incredible. In the free time i will try to analyze your source code. I am curious how to do this "fake" 3D :)

Author :


If you analysis code maybe you could do a fork with your comments. I’m not developping atm but it was not easy to understand when i have had a look on code. It’s a really good project and i think it’s could be great to have a good study of the code and explain to all how to use it, personnalize and use motor for any imaginable game (or adaptation) or be able to use other methode technics explained by bfx in Affine3D or methods explained in Affine.  I don’t think that metohds explained by Steph here could be easy to use with this motor but maybe i’m wrong

Author :


I have not studied this piece of code thoroughly, but this is a very “classic” problem, and the implementation looks as “basic” as this type of problem can be.

This looks 3D, but this is a 2D problem :

  • imagine you are in a place with a fixed ceiling and a fixed floor, every wall has the same height
  • More interestingly, at every angle you can look at, you can see one and only one wall.
  • Thus, to draw this "3D" scene, you "just" have to determine 2 things per view angle (i.e. per pixel column) :
    • Which wall you are looking to, and which part of the wall -> this gives you a texture coordinate
    • How far it is -> this gives you a scale factor
    • -> this is a problem of finding the intersection of a view line and a list of walls

Angles and scale factors are stored in look-up tables, to make things faster.

My 2 cents, I hope this is clear enough. I can invite you to read "Game Engine Black Book : Wolfenstein 3D" by Fabien Sanglard if you want to know more (there is much more than raycasting in this book).

Author :


These two are really good resources: