diff options
| author | tslil clingman <> | 2021-09-05 20:45:43 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-09-05 20:45:43 -0400 |
| commit | e95d2bd264df2682f05db4a5873594af52a7583a (patch) | |
| tree | 62a9b720b4377b67f05a88c728157282c246274f /src/main.zig | |
| parent | 1c4874c9f2855ee776bf8d5c35aef3d245c0519d (diff) | |
Changed map scaling, texture indexing, finished object rendering!
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 23 |
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 //-------------------------------------------------------------------------- |
