summaryrefslogtreecommitdiff
path: root/src/context.zig
diff options
context:
space:
mode:
authorAlec Goncharow <alec@goncharow.dev>2024-02-11 23:00:27 -0500
committerAlec Goncharow <alec@goncharow.dev>2024-02-11 23:00:27 -0500
commit0085d899650006679365a1d68dcb43650c297486 (patch)
tree5b5f5c292d8dd4bc76f98e2d560fe26ba654f69e /src/context.zig
parentdb229ae38f04e8a6b9759c1e5208af75b81344aa (diff)
some cheeky animation action
Diffstat (limited to 'src/context.zig')
-rw-r--r--src/context.zig14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/context.zig b/src/context.zig
index f3e88f2..0bffbd4 100644
--- a/src/context.zig
+++ b/src/context.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const rl = @cImport(@cInclude("raylib.h"));
const root = @import("root.zig");
+const Animation = @import("Animation.zig");
pub var camera: rl.Camera2D = undefined;
pub var grid: []root.MyRect = undefined;
@@ -9,7 +10,6 @@ pub const Grid = struct {
buffer: std.MultiArrayList(root.Hex),
cursor: usize,
size: usize,
- const Self = @This();
const GridError = error{
OutOfBounds,
@@ -30,14 +30,14 @@ pub const Grid = struct {
}
// should only be used when standing up the buffer, afterwards should use q, r indexing
- pub fn initPush(self: *Self, hex: root.Hex) GridError!void {
+ pub fn initPush(self: *Grid, hex: root.Hex) GridError!void {
if (self.cursor >= self.size * 2) {
return GridError.OutOfBounds;
}
self.buffer.insertAssumeCapacity(self.cursor, hex);
}
- pub fn set(self: *Self, hex: root.Hex) GridError!void {
+ pub fn set(self: *Grid, hex: root.Hex) GridError!void {
const idx = hex.qr[1] * self.size + hex.qr[0];
if (idx >= self.size * 2) {
return GridError.OutOfBounds;
@@ -50,5 +50,13 @@ pub var hex_grid: Grid = undefined;
pub var hovered_coords: root.HexCoord = root.HexCoord{ .q = 0, .r = 0 };
pub var hovered_handle: ?usize = null;
+pub const Dude = struct {
+ world_coords: rl.Vector2,
+ hex_coords: root.HexCoord,
+ target_coords: root.HexCoord,
+ animation: Animation,
+};
+pub var main_dude: Dude = undefined;
+
var Gpa = std.heap.GeneralPurposeAllocator(.{}){};
pub var gpa: std.mem.Allocator = Gpa.allocator();