diff options
| author | Nic Gaffney <gaffney_nic@protonmail.com> | 2024-06-20 00:44:24 -0500 |
|---|---|---|
| committer | Nic Gaffney <gaffney_nic@protonmail.com> | 2024-06-20 00:44:24 -0500 |
| commit | 0dc97d45f1b228f6f3b9feb1773b972eca343766 (patch) | |
| tree | 3d133ce030dbd23632759edb31ab4c1878d20517 /src/main.zig | |
| parent | 2374e1f1a11d62ee579d25a39b24312a68e7387e (diff) | |
| download | particle-sim-0dc97d45f1b228f6f3b9feb1773b972eca343766.tar.gz | |
Added load / save feature with simple CSV parsing
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig index 02830e5..118609a 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4,6 +4,7 @@ const z = @import("zgui"); const part = @import("particle.zig"); const cfg = @import("config.zig"); const img = @import("imgui.zig"); +const rules = @import("rules.zig"); const c = @cImport({ @cDefine("NO_FONT_AWESOME", "1"); @@ -11,8 +12,8 @@ const c = @cImport({ }); pub fn main() !void { - cfg.rules = part.ruleMatrix(); - part.printRules(cfg.rules); + cfg.rules = rules.ruleMatrix(); + rules.printRules(cfg.rules); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); @@ -35,6 +36,10 @@ pub fn main() !void { var particles = try part.initParticles(gpa.allocator(), cfg.initialParticles); defer particles.deinit(gpa.allocator()); + const buf = try gpa.allocator().allocSentinel(u8, 128, 0); + std.mem.copyForwards(u8, buf, "Absolute File Path" ++ .{0}); + defer gpa.allocator().free(buf); + while (!rl.windowShouldClose()) { if (particles.items(.x).len < cfg.particleCount) { for (0..@intCast(cfg.particleCount - @as(i32, @intCast(particles.items(.x).len)))) |_| { @@ -54,6 +59,6 @@ pub fn main() !void { part.updateVelocities(particles, cfg.rules); part.updatePosition(particles); part.draw(particles); - try img.update(); + try img.update(gpa.allocator(), buf); } } |
