aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig5
-rw-r--r--src/player.zig11
2 files changed, 9 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig
index d76e424..3c425ba 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -62,14 +62,13 @@ pub fn main() !void {
}
}
- map.cells.items[16 * 7 + 7] = level.Cell{ .floor_height = level.Cell.DEFAULT_HEIGHT, .lower_texture = 1 };
- map.cells.items[16 * 7 + 6] = level.Cell{
+ map.cells.items[16 * 7 + 7] = level.Cell{
.floor_height = 0.5,
.ceiling_height = 2,
.lower_texture = 1,
.upper_texture = 1,
.floor_texture = 1,
- .ceiling_texture = 1,
+ .ceiling_texture = 2,
.draw_down = true,
};
diff --git a/src/player.zig b/src/player.zig
index c8fc4df..8fe0002 100644
--- a/src/player.zig
+++ b/src/player.zig
@@ -383,13 +383,16 @@ pub fn Player(PlaneWidth: f32, PlaneHeight: f32) type {
if (draw_lower) {
// which texture index?
const t_lower_off = cell.lower_texture * td;
- // now we have what we need to draw the face, and
- // update the z-buffer
- const constrained_top = std.math.min(top_of_floor, lowest_drawn);
+ // Note the bizarre rounding we have to do to avoid artifacts
+ const constrained_top = std.math.min(std.math.floor(top_of_floor), std.math.ceil(lowest_drawn));
+ const stop = @floatToInt(i32, highest_drawn);
var zb_y = @floatToInt(i32, constrained_top);
var pix_y = @floatToInt(usize, std.math.ceil(std.math.max(PlaneHeight - constrained_top, 0)));
var texel_y = (top_of_floor - constrained_top) / nominal_length;
- while (zb_y > @floatToInt(i32, highest_drawn)) : ({
+
+ // now we have what we need to draw the face,
+ // and update the z-buffer
+ while (zb_y > stop) : ({
zb_y -= 1;
pix_y += 1;
texel_y += inv_nom_len;