diff --git a/src/main.zig b/src/main.zig index ef33989..a7f8bc9 100644 --- a/src/main.zig +++ b/src/main.zig @@ -79,11 +79,11 @@ const Emitter = struct { pub fn init(self: *Emitter) !void { var xrnr = randMinMaxFloat(-1, 1); var yrnr = randMinMaxFloat(-0.5, 0.5); - self.particles = try allocator.alloc(Particle, 500000); + self.particles = try allocator.alloc(Particle, 10000); for (self.particles) |*p| { xrnr = randMinMaxFloat(0, 2); yrnr = randMinMaxFloat(0, 2); - p.* = Particle{ .velocity = .{ .a = .{ .x = 1, .y = -3 } }, .acceleration = .{ .a = .{ .x = xrnr, .y = yrnr } } }; + p.* = Particle{ .velocity = .{ .a = .{ .x = 0, .y = 0 } }, .acceleration = .{ .a = .{ .x = xrnr, .y = yrnr } } }; } } pub fn emit(self: *Emitter, count: u32, xaccel: f32, yaccel: f32) void { @@ -180,10 +180,9 @@ pub fn main() anyerror!void { rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second const file = try plot.open("plot.dat"); - try plot.log(file,"test\ntest2\n"); - var plotStr : []u8 = undefined; var plotStrBuf : [128]u8 = undefined; + try plot.log(file,"acceleration, position, velocity, show\n"); while (!rl.windowShouldClose()) { // Detect window close button or ESC key rl.beginDrawing(); @@ -208,7 +207,7 @@ pub fn main() anyerror!void { rl.endBlendMode(); - plotStr = try std.fmt.bufPrint(&plotStrBuf,"{}, {}, {}\n",.{emitter.particles[0].acceleration.a.x,emitter.particles[0].position.a.x,emitter.particles[0].velocity.a.x}); + plotStr = try std.fmt.bufPrint(&plotStrBuf,"{d}, {d}, {d}, {d}\n",.{emitter.particles[0].acceleration.a.x,emitter.particles[0].position.a.x,emitter.particles[0].velocity.a.x,emitter.particles[0].show}); try plot.log(file,plotStr); emitter.update(texture); diff --git a/zig-out/bin/raylib-test b/zig-out/bin/raylib-test index 8759ba8..d83ced3 100755 Binary files a/zig-out/bin/raylib-test and b/zig-out/bin/raylib-test differ