aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/main.zig b/src/main.zig
index 8129ae2..cf3839d 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -47,7 +47,7 @@ fn renderSlice(
const xpos = @intToFloat(f32, col) * HFact;
const ypos = ScreenHeight / 2 + (PlaneHeight / 2 - top) * VFact;
- const tind = @as(c_int, texture) * @floatToInt(c_int, 1 + TextureDim);
+ const tind = @as(c_int, texture) * @floatToInt(c_int, TextureDim);
const left = tind + @floatToInt(c_int, texfrac * TextureDim);
sprite.setPosition(.{ .x = xpos, .y = ypos });
@@ -63,7 +63,7 @@ pub fn main() !void {
//--------------------------------------------------------------------------
var player = try Player(PlaneWidth, PlaneHeight).new(
- 15, // x coord
+ 7, // x coord
1.5, // y coord
PI / 2.0, // angle
);
@@ -71,21 +71,22 @@ pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
- var map = try Map.new(32, 32, &gpa.allocator);
+ var map = try Map.new(16, 16, &gpa.allocator);
defer map.deinit();
var y: u32 = 0;
- while (y < 32) : (y += 1) {
- map.cells.items[y * 32 + 00] = Cell{ .height = MAX_HEIGHT };
- map.cells.items[y * 32 + 31] = Cell{ .height = MAX_HEIGHT, .wall_texture = 2 };
- map.cells.items[31 * 32 + y] = Cell{ .height = MAX_HEIGHT };
- map.cells.items[00 * 32 + y] = Cell{ .height = MAX_HEIGHT };
+ while (y < 16) : (y += 1) {
+ map.cells.items[y * 16 + 00] = Cell{ .height = MAX_HEIGHT };
+ map.cells.items[y * 16 + 15] = Cell{ .height = MAX_HEIGHT, .wall_texture = 2 };
+ map.cells.items[15 * 16 + y] = Cell{ .height = MAX_HEIGHT };
+ map.cells.items[00 * 16 + y] = Cell{ .height = MAX_HEIGHT };
}
- map.cells.items[32 * 15 + 15] = Cell{ .height = MAX_HEIGHT, .wall_texture = 1 };
- map.cells.items[32 * 15 + 14] = Cell{ .height = MAX_HEIGHT / 3, .wall_texture = 1, .floor_texture = 1 };
+ map.cells.items[16 * 7 + 7] = Cell{ .height = MAX_HEIGHT, .wall_texture = 1 };
+ map.cells.items[16 * 7 + 6] = Cell{ .height = MAX_HEIGHT / 3, .wall_texture = 1, .floor_texture = 1 };
- try map.objects.append(Object{.pos_x = 14.5, .pos_y = 16.5, .texture = 0, .height = 1.5, .width = 1});
+ try map.objects.append(Object{.pos_x = 6.5, .pos_y = 8.5, .texture = 0, .height = 1, .width = 1});
+ try map.objects.append(Object{.pos_x = 4, .pos_y = 8.5, .texture = 1, .height = 1, .width = 1});
// Initialise SFML
//--------------------------------------------------------------------------