2022-06-27 03:39:57 +00:00
|
|
|
pub const Point = packed struct {
|
2022-07-02 12:16:29 +00:00
|
|
|
x: i16,
|
|
|
|
y: i16,
|
|
|
|
pub fn init(x: i16, y: i16) @This() {
|
2022-06-27 03:39:57 +00:00
|
|
|
return @This() {
|
|
|
|
.x = x,
|
|
|
|
.y = y,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn equals(this: @This(), other: @This()) bool {
|
|
|
|
return this.x == other.x and this.y == other.y;
|
|
|
|
}
|
2022-07-02 12:16:29 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
}
|
2022-06-27 03:39:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub const Rect = packed struct {
|
|
|
|
base: Point,
|
2022-07-02 00:22:38 +00:00
|
|
|
width: u8,
|
|
|
|
height: u8,
|
|
|
|
pub fn init(base: Point, width: u8, height: u8) @This() {
|
2022-06-27 03:39:57 +00:00
|
|
|
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 {
|
2022-07-02 17:40:41 +00:00
|
|
|
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;
|
2022-06-27 03:39:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
pub const Direction = enum(u2) {
|
|
|
|
Up,
|
|
|
|
Down,
|
|
|
|
Left,
|
|
|
|
Right,
|
2022-07-02 02:51:31 +00:00
|
|
|
|
|
|
|
pub fn opposite(this: @This()) @This() {
|
|
|
|
switch(this) {
|
|
|
|
.Up => .Down,
|
|
|
|
.Down => .Up,
|
|
|
|
.Left => .Right,
|
|
|
|
.Right => .Left,
|
|
|
|
}
|
|
|
|
}
|
2022-07-01 17:19:50 +00:00
|
|
|
};
|
|
|
|
|
2022-07-01 22:05:55 +00:00
|
|
|
pub const Trigger = struct {
|
|
|
|
aura: Rect,
|
|
|
|
direction: Direction,
|
|
|
|
dialogue: []const u8,
|
|
|
|
};
|
|
|
|
|
2022-07-02 01:18:54 +00:00
|
|
|
pub const Tileset = enum(u2) {
|
|
|
|
Rpg,
|
|
|
|
Dungeon,
|
2022-07-02 02:51:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub const State = enum {
|
|
|
|
Title,
|
|
|
|
StoryDump,
|
|
|
|
Gameplay,
|
2022-07-02 18:18:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub var state: State = .Gameplay;
|