pub const Point = packed struct { x: i16, y: i16, pub fn init(x: i16, y: i16) @This() { return @This() { .x = x, .y = y, }; } pub fn equals(this: @This(), other: @This()) bool { return this.x == other.x and this.y == other.y; } pub fn add(this: @This(), other: @This()) @This() { return @This() { .x = this.x + other.x, .y = this.y + other.y, }; } pub fn sub(this: @This(), other: @This()) @This() { return @This() { .x = this.x - other.x, .y = this.y - other.y, }; } }; pub const Rect = packed struct { base: Point, width: u8, height: u8, pub fn init(base: Point, width: u8, height: u8) @This() { return @This() { .base = base, .width = width, .height = height, }; } pub fn inside(this: @This(), point: Point) bool { return point.x >= this.base.x and point.x < this.base.x + this.width and point.y >= this.base.y and point.y < this.base.y + this.height; } pub fn collides(this: @This(), other: @This()) bool { return this.base.x < other.base.x + other.width and this.base.x + this.width > other.base.x and this.base.y < other.base.y + other.height and this.base.y + this.height > other.base.y; } }; pub const Direction = enum(u2) { Up, Down, Left, Right, pub fn opposite(this: @This()) @This() { switch(this) { .Up => .Down, .Down => .Up, .Left => .Right, .Right => .Left, } } }; pub const Trigger = struct { aura: Rect, direction: Direction, dialogue: []const u8, }; pub const Tileset = enum(u2) { Rpg, Dungeon, }; pub const State = enum { Title, StoryDump, Gameplay, }; pub var state: State = .Gameplay;