Log In  

Cart #mifudotuse-0 | 2023-03-10 | Code ▽ | Embed ▽ | No License
1


Hello,
I'm been trying to play around with raycasting and I hit lots of problems with the maths so tried copying some code from cast.p8. it kinda works but I'm clearly making some silly mistake when I try to render the image to screen. I'm taking the length of each ray (from left to right, one for each x-axis column), and calculating the height of the wall it hits by just dividing an arbitrary number by the ray length.
Then for each column I'm drawing a line which has the y-value being half the height of the screen + and - half the height of the wall.
In my head this makes sense, but when I render it out the walls look fine, but I'm getting tons of noise above and below the walls.
Does anyone have any idea what I'm doing wrong?

--draw walls
wallH = (1500) / tdist --set the wall height by distance, smaller the distance the bigger the wall
if(wallH > 127) then wallH = 127 end --cap the wall height
line(sx, 64-wallH/2, sx, 64+wallH/2) --sx is the x-coordinate

P#126911 2023-03-10 14:19 ( Edited 2023-03-10 14:21)


[Please log in to post a comment]