diff --git a/src/main.zig b/src/main.zig index a5d5f9e..7c459bf 100644 --- a/src/main.zig +++ b/src/main.zig @@ -14,8 +14,8 @@ pub fn main() anyerror!void { // MEMORY ALLOCATOR //-------------------------------------------------------------------------------------- - var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); - var arenaAlloc = arena.allocator(); + var gpAlloc = std.heap.GeneralPurposeAllocator(.{}){}; + var allocator = gpAlloc.allocator(); // Initialization //-------------------------------------------------------------------------------------- @@ -39,7 +39,7 @@ pub fn main() anyerror!void // .{ .box = .{ .x = 100, .y = 0, .width = 20, .height = 200, }, .texture = null } // }; - var objects = std.ArrayList(obj.Object).init(arenaAlloc); + var objects = std.ArrayList(obj.Object).init(allocator); try objects.append(.{ .box = .{ .x = 0, .y = 0, .width = 300, .height = 20, }, .texture = null }); try objects.append(.{ .box = .{ .x = 100, .y = 0, .width = 20, .height = 200, }, .texture = null }); @@ -120,7 +120,7 @@ pub fn main() anyerror!void // tile drawing - for (map.tiles.allocatedSlice()) |tile| { + for (map.tiles.items) |tile| { var dispTile = .{ .x = tile.box.x, .y = tile.box.y - tile.box.height, .width = tile.box.width, .height = tile.box.height }; rl.DrawRectangleRec(dispTile, rl.GRAY); diff --git a/src/physics.zig b/src/physics.zig index d088658..1a12d44 100644 --- a/src/physics.zig +++ b/src/physics.zig @@ -49,7 +49,7 @@ pub const movement = struct { pub fn ApplyPlayerCollisions(player: *obj.Player, map: obj.Map) void { // for every tile - for (map.tiles.allocatedSlice()) |tile| { + for (map.tiles.items) |tile| { // check if any collision occured if ( rl.CheckCollisionRecs(player.box, tile.box) ) {