aboutsummaryrefslogtreecommitdiff
path: root/src/raycast.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/raycast.zig')
-rw-r--r--src/raycast.zig4
1 files changed, 2 insertions, 2 deletions
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));