Hi there! I have one issue for now. I'm creating a RayCasting application, and for my floor and ceiling I'm trying to use Mode7 for rendering (I think this is easier to understand). but, I cant align the RayCasting walls with the mode7 floor. I use a rotate matrix to make the rotation of floor. Do you know what a need to think in the implementation to fix that? Or do you know if there is some tutorial explaining about it? Thanks!!! (Check the image below for understand)
Here is my mode7 code:
function mode7() {
let _x = 0;
let _y = 0;
let z = 0;
let sin = Math.sin(degreeToRadians(data.player.angle));
let cos = Math.cos(degreeToRadians(data.player.angle));
for(let y = data.projection.halfHeight; y < data.projection.height; y++) {
for(let x = 0; x < data.projection.width; x++) {
_x = ((data.projection.width - x) * cos) - (x * sin);
_y = ((data.projection.width - x) * sin) + (x * cos);
_x /= z;
_y /= z;
if(_y < 0) _y *= -1;
if(_x < 0) _x *= -1;
_y *= 8.0;
_x *= 8.0;
_y %= data.floorTextures[0].height;
_x %= data.floorTextures[0].width;
screenContext.fillStyle = data.floorTextures[0].data[Math.floor(_x) + Math.floor(_y) * data.floorTextures[0].width];
screenContext.fillRect(x, y, 1, 1);
}
z += 1;
}
}