From f59d8c3b31781c4093aa526d7f66544d132765e9 Mon Sep 17 00:00:00 2001 From: tslil clingman <> Date: Fri, 10 Sep 2021 00:02:18 -0400 Subject: Textures repeat rather than scale? --- src/raycast.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/raycast.zig') diff --git a/src/raycast.zig b/src/raycast.zig index 6711cb2..41fea5d 100644 --- a/src/raycast.zig +++ b/src/raycast.zig @@ -287,7 +287,7 @@ pub fn Player(PlaneWidth: f32, PlaneHeight: f32) type { // as well as the fraction we'll be drawing const draw_length = top - highest_point; - const draw_frac = std.math.clamp(draw_length / total_length, 0, 1); + const draw_frac = cell.height * std.math.clamp(draw_length / total_length, 0, 1); // we need the distance to calculate the fractional // part of the relevant coordinate for texture @@ -300,7 +300,7 @@ pub fn Player(PlaneWidth: f32, PlaneHeight: f32) type { if ((horizontal_hit and sinra < 0) or (!horizontal_hit and cosra > 0)) texfrac = 1 - texfrac; // draw the wall - renderSlice(window, walls_sprite, col, top, total_length, draw_frac, texfrac, cell.wall_texture); + renderSlice(window, walls_sprite, col, top, total_length / cell.height, draw_frac, texfrac, cell.wall_texture); // record that there's a wall here in the z_buffer var y = @floatToInt(i32, std.math.min(top, PlaneHeight - 1)); -- cgit v1.3.1