aboutsummaryrefslogtreecommitdiff
path: root/src/raycast.zig
diff options
context:
space:
mode:
authortslil clingman <>2021-09-10 00:02:18 -0400
committertslil clingman <>2021-09-10 00:02:18 -0400
commitf59d8c3b31781c4093aa526d7f66544d132765e9 (patch)
tree732a1fa0cb1a9d5b543c69074f17fedbc0eebfa6 /src/raycast.zig
parent9e15cb6352c9afc771c41451dea86b93e35349e5 (diff)
Textures repeat rather than scale?
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));