Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Raycasting with DDA Algorithm
- ThreeLived
-
Scratcher
100+ posts
Raycasting with DDA Algorithm
Hello. I have been working on a raycaster for a while and i finished the main part. Then i tried implementind DDA (using this) and no matter how hard i tried, just couldn't do it.
I had implemented regular raycasting as you can see here:
(some artifacts are from using high quality pen from turbowarp)

but when i added DDA it looked like this:

Each grey pixel represents 1 step in the algorithm. for DDA i make it only move 1 pixel so i could see what it is doing better.
I double checked the code many times, and all seemed fine. i looked at the variables for it and they seemed like they were also fine, so i dont really know whats going on. can anyone help?
I had implemented regular raycasting as you can see here:
(some artifacts are from using high quality pen from turbowarp)

but when i added DDA it looked like this:

Each grey pixel represents 1 step in the algorithm. for DDA i make it only move 1 pixel so i could see what it is doing better.
I double checked the code many times, and all seemed fine. i looked at the variables for it and they seemed like they were also fine, so i dont really know whats going on. can anyone help?
Last edited by ThreeLived (July 12, 2025 21:59:56)
- awesome-llama
-
Scratcher
1000+ posts
Raycasting with DDA Algorithm
I don't immediately recognise a specific problem from what you have posted.
Perhaps you could compare it with my own code? https://scratch.mit.edu/projects/762477671/
Perhaps you could compare it with my own code? https://scratch.mit.edu/projects/762477671/
- ThreeLived
-
Scratcher
100+ posts
Raycasting with DDA Algorithm
When i tried replacing some of my code with your code, i don't know why but each quarter of rays sent got distributed between 4 directions
so 25% of them were going up, another 25% going right and so on.
The raycasting itself seems to be working though.

so 25% of them were going up, another 25% going right and so on.
The raycasting itself seems to be working though.

- N8_D_GR8_1
-
Scratcher
1000+ posts
Raycasting with DDA Algorithm
If you can, please share your project. You can use share.turbowarp.org if you don't want to post it on your account.
For me, it always helps to really slow down the execution speed and use say blocks to understand what the program is doing wrong.
For me, it always helps to really slow down the execution speed and use say blocks to understand what the program is doing wrong.
- Discussion Forums
- » Help with Scripts
-
» Raycasting with DDA Algorithm