diff options
| author | tslil clingman <> | 2021-09-12 00:17:24 -0400 |
|---|---|---|
| committer | tslil clingman <> | 2021-09-12 00:17:24 -0400 |
| commit | 027b973d7550ac2e72e5de1e2155e26b35f16353 (patch) | |
| tree | c83de5e5ed38dc77e8c07e0f2561963cc7919e51 /src/main.zig | |
| parent | 842d498f81e4733452e03f01d1c570ab5bb02771 (diff) | |
More efficient surface rendering!
Now, outside of sprites, every pixel on the screen is draw at most
once. Hoorah. Unfortunately things still seem to be a little slow,
perhaps its the z_buffer access or the fact that vertical floor slice
drawing is bad?
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/main.zig b/src/main.zig index 218ba92..c44b5e6 100644 --- a/src/main.zig +++ b/src/main.zig @@ -55,7 +55,7 @@ pub fn main() !void { } map.cells.items[16 * 7 + 7] = level.Cell{ .height = constants.MAX_HEIGHT, .wall_texture = 1 }; - map.cells.items[16 * 7 + 6] = level.Cell{ .height = constants.MAX_HEIGHT / 4, .wall_texture = 1, .floor_texture = 0 }; + map.cells.items[16 * 7 + 6] = level.Cell{ .height = constants.MAX_HEIGHT / 4, .wall_texture = 1, .floor_texture = 1 }; try map.objects.append(level.Object{ .pos_x = 5.5, .pos_y = 7.5, .pos_z = 1, .texture = 2, .height = 1, .width = 1 }); try map.objects.append(level.Object{ .pos_x = 4, .pos_y = 8.5, .texture = 1, .height = 1, .width = 1 }); @@ -103,18 +103,18 @@ pub fn main() !void { defer objects_sprite.destroy(); // Load floor image - var floors_image = try sf.Image.createFromFile("floors.png"); - defer floors_image.destroy(); + var surfaces_image = try sf.Image.createFromFile("surfaces.png"); + defer surfaces_image.destroy(); - var rendered_floors_texture = try sf.Texture.create(.{ .x = constants.PlaneWidth, .y = constants.PlaneHeight }); - defer rendered_floors_texture.destroy(); - rendered_floors_texture.setSmooth(false); + var rendered_surfaces_texture = try sf.Texture.create(.{ .x = constants.PlaneWidth, .y = constants.PlaneHeight }); + defer rendered_surfaces_texture.destroy(); + rendered_surfaces_texture.setSmooth(false); - var rendered_floors_sprite = try sf.Sprite.createFromTexture(rendered_floors_texture); - defer rendered_floors_sprite.destroy(); + var rendered_surfaces_sprite = try sf.Sprite.createFromTexture(rendered_surfaces_texture); + defer rendered_surfaces_sprite.destroy(); - rendered_floors_sprite.setPosition(.{ .x = 0, .y = 0 }); - rendered_floors_sprite.setScale(.{ .x = constants.HFact, .y = constants.VFact }); + rendered_surfaces_sprite.setPosition(.{ .x = 0, .y = 0 }); + rendered_surfaces_sprite.setScale(.{ .x = constants.HFact, .y = constants.VFact }); // Start your engines! //-------------------------------------------------------------------------- @@ -169,9 +169,9 @@ pub fn main() !void { window, walls_sprite, objects_sprite, - floors_image, - rendered_floors_texture, - rendered_floors_sprite, + surfaces_image, + rendered_surfaces_texture, + rendered_surfaces_sprite, map, ); |
