diff --git a/src/main.zig b/src/main.zig index 9474e10..a8aab32 100644 --- a/src/main.zig +++ b/src/main.zig @@ -2,6 +2,7 @@ const std = @import("std"); const rl = @import("raylib"); const rg = @import("raygui"); const pr = @import("primitives.zig"); +const allocator = std.heap.page_allocator; var prng = std.rand.DefaultPrng.init(124346556); @@ -85,8 +86,8 @@ pub fn main() anyerror!void { var posx : i32 = 0; var posy : i32 = 0; - var p1 : [5000]Particle = undefined; - for (&p1) |*p| { + const p1 = try allocator.alloc(Particle,5000); + for (p1) |*p| { xrnr = rand.float(f32); yrnr = rand.float(f32); p.* = Particle{.velocity = .{.a = .{.x = 1,.y = -3}},.acceleration = .{.a = .{.x=xrnr,.y=yrnr}}}; @@ -125,7 +126,7 @@ pub fn main() anyerror!void { else =>{}, } } - for (&p1) |*p| { + for (p1) |*p| { p.update(); p.applyGravity(2); if(p.position.a.x >= -(screenWidth/2)){ diff --git a/zig-out/bin/raylib-test b/zig-out/bin/raylib-test index d519144..b5d0b64 100755 Binary files a/zig-out/bin/raylib-test and b/zig-out/bin/raylib-test differ