Initial commit

This commit is contained in:
2026-04-28 17:50:46 +02:00
commit edfc54b927
10 changed files with 423 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
const std = @import("std");
const Vector2 = @import("raylib").Vector2;
const c = @import("../constants.zig");
const Node = @import("node.zig").Node;
const Road = @import("road.zig").Road;
pub const NodeManager = struct {
nodes: std.ArrayList(Node),
temp_node: ?*Node,
pub fn init() NodeManager {
return .{
.nodes = .empty,
.temp_node = null,
};
}
pub fn deinit(self: *NodeManager, allocator: std.mem.Allocator) void {
self.nodes.deinit(allocator);
}
pub fn draw(self: *const NodeManager, pos: Vector2) void {
for (self.nodes.items) |node| {
node.draw();
}
if (self.temp_node) |node| {
// Temporary node that points at the cursor
const cur_node = Node.init(0, pos);
// Temporary road that is to be drawn as one in the making
const road: Road = .init(0, node, &cur_node);
road.draw();
node.*.draw(c.NODE_TEMP_COLOUR);
cur_node.draw(c.NODE_CURSOR_COLOUR);
}
}
};