Initial commit
This commit is contained in:
43
src/simulator.zig
Normal file
43
src/simulator.zig
Normal file
@@ -0,0 +1,43 @@
|
||||
const std = @import("std");
|
||||
const rl = @import("raylib");
|
||||
|
||||
const NodeManager = @import("infrastructure/node_manager.zig").NodeManager;
|
||||
const RoadManager = @import("infrastructure/road_manager.zig").RoadManager;
|
||||
|
||||
pub const Simulator = struct {
|
||||
allocator: std.mem.Allocator,
|
||||
node_man: NodeManager,
|
||||
road_man: RoadManager,
|
||||
|
||||
pub fn init(new_allocator: std.mem.Allocator) Simulator {
|
||||
return .{
|
||||
.allocator = new_allocator,
|
||||
.node_man = .init(),
|
||||
.road_man = .init(),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn deinit(self: *Simulator) void {
|
||||
self.road_man.deinit(self.allocator);
|
||||
self.node_man.deinit(self.allocator);
|
||||
}
|
||||
|
||||
pub fn draw(self: *const Simulator, pos: rl.Vector2) void {
|
||||
rl.clearBackground(.light_gray);
|
||||
|
||||
self.road_man.draw();
|
||||
self.node_man.draw(pos);
|
||||
}
|
||||
|
||||
pub fn handleInput(self: *Simulator, pos: rl.Vector2) void {
|
||||
self.handleMouseInput(pos);
|
||||
}
|
||||
|
||||
fn handleMouseInput(self: *Simulator, pos: rl.Vector2) void {
|
||||
if (rl.isMouseButtonReleased(.left)) self.leftClickEvent(pos);
|
||||
}
|
||||
|
||||
fn leftClickEvent(self: *Simulator, pos: rl.Vector2) void {
|
||||
// TODO
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user