Additional fixes and todo plans

This commit is contained in:
2026-04-28 22:50:04 +02:00
parent ccbf7344b5
commit 37e2f36ae9
5 changed files with 29 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
const std = @import("std");
const rl = @import("raylib");
const c = @import("constants.zig");
const NodeManager = @import("infrastructure/node_manager.zig").NodeManager;
const RoadManager = @import("infrastructure/road_manager.zig").RoadManager;
@@ -8,12 +9,15 @@ pub const Simulator = struct {
allocator: std.mem.Allocator,
node_man: NodeManager,
road_man: RoadManager,
// vars
auto_continue: bool,
pub fn init(new_allocator: std.mem.Allocator) Simulator {
return .{
.allocator = new_allocator,
.node_man = .init(),
.road_man = .init(),
.auto_continue = false,
};
}
@@ -23,7 +27,7 @@ pub const Simulator = struct {
}
pub fn draw(self: *const Simulator, pos: rl.Vector2) void {
rl.clearBackground(.light_gray);
rl.clearBackground(c.BACKGROUND_COLOR);
self.road_man.draw();
self.node_man.draw(pos);
@@ -35,6 +39,8 @@ pub const Simulator = struct {
}
fn handleKeyboardInput(self: *Simulator) void {
self.auto_continue = rl.isKeyDown(.left_control);
if (rl.isKeyReleased(.c)) self.clear();
}
@@ -54,7 +60,7 @@ pub const Simulator = struct {
std.debug.panic("Failed to add a new road or assigning its nodes: {}\n", .{err});
};
self.node_man.temp_node = null;
self.node_man.temp_node = if (self.auto_continue) cur_node else null;
return;
}