aboutsummaryrefslogtreecommitdiff
path: root/src/level.zig
diff options
context:
space:
mode:
authortslil clingman <>2021-10-22 17:21:10 -0400
committertslil clingman <>2021-10-22 17:36:22 -0400
commit5cecadb81ccab1a2e6ff264349f5fa73a720db9f (patch)
tree999831c7d77f954e8fb65667e6922f2d2db6e2e9 /src/level.zig
parent852a98fe4a56109f0f4947611a75d7a0eaea0bb5 (diff)
Specialise layers to be either lists of vertices or squares
Diffstat (limited to 'src/level.zig')
-rw-r--r--src/level.zig31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/level.zig b/src/level.zig
index f277b19..31d86df 100644
--- a/src/level.zig
+++ b/src/level.zig
@@ -17,35 +17,30 @@
const std = @import("std");
-pub const Layer = struct {
+pub const Polygon = union(enum) {
pub const MAX_VERTS = 16;
- height : f32 = 0,
- vertical_texture : u8 = 0,
- vertical_texture_scale : f32 = 4,
- horizontal_texture : u8 = 0,
- // What happened to this error? Is it comptime?
+ square: void,
vertices: std.BoundedArray([2]f32, MAX_VERTS),
};
+pub const Layer = struct {
+ height: f32 = 0,
+ vertical_texture: u8 = 0,
+ vertical_texture_scale: f32 = 4,
+ horizontal_texture: u8 = 0,
+
+ polygon: Polygon,
+};
+
pub const Cell = struct {
pub const MAX_LAYERS = 16;
- // floor_height: f32 = 0,
- // ceiling_height: f32 = DEFAULT_HEIGHT,
- // draw_down: bool = false,
- // lower_texture: u8 = 0,
- // upper_texture: u8 = 0,
- // floor_texture: u8 = 0,
- // ceiling_texture: u8 = 2,
- lower_layers : std.BoundedArray(Layer, MAX_LAYERS),
+ lower_layers: std.BoundedArray(Layer, MAX_LAYERS),
- // I'm not sure how i feel about reaching into the implementation of
- // BoundedArray like this. Surely there should be an ``.empty'' or something
- // default?
fn empty() !Cell {
const lower_layers = try std.BoundedArray(Layer, MAX_LAYERS).init(0);
- return Cell{ . lower_layers = lower_layers };
+ return Cell{ .lower_layers = lower_layers };
}
pub const DEFAULT_HEIGHT: f32 = 4;