im new around here, hope everything is going sweet for all of you. I come for theory help with a classic raycast algorithm (currently, based on DDA). The problem is not with the algorithm itself, but with the floor rendering code.
I left the code of my raycast render method below (actual DDA implementation itsis left out, iI think that's working as expected). The basic idea its use PLAYER_HEIGHTit uses PLAYER_HEIGHT (position of camera, currently set to HORIZON), and the formula PLAYER_HEIGHT/(y- HORIZON)PLAYER_HEIGHT/(y- HORIZON). In the canvas, the bottom pixel of y itsis equal to SCREEN_HEIGHTSCREEN_HEIGHT, and goes “up” until it reach HORIZON - 1reaches (canvasHORIZON - 1. Canvas element pixels goesgo from 0,0/topleftcorner (top left corner) to screen_width,screen_height/bottomrightcornerscreen_width, screen_height (bottom right corner). ThatsThat's the distance that will be used for interpolating the floor coordinates x and y according to the vector direction of the player and a camera plane perpendicular to the direction vector.
The main problem itsis in my rendering floor technique. New tiles “appears”“appear” below the walls. The desired effect would be, if there is a wall in a map position (7,4) the floor tiles around that should be always the same. But right now, as the player moves, “new” tiles slide from behind the wall, so depending ofon the player position and angle, near to (7,4) the floor tile may be appear white or blue, so itsit is not “sync”“in sync”.
I think the problem itsis the distance of the wall iI get using DDA and the distance related to the difference between the current row in the screen space and my HORIZON itsHORIZON is different, they are not “sync”“in sync” and itsit is normal because the are two different “types” of distances? I'm lost here. Thank you all for taking your time with this.
