From c003155edda7ab1ed0399f428e5d072fd3b0f5df Mon Sep 17 00:00:00 2001 From: IgLemp <87860192+IgLemp@users.noreply.github.com> Date: Thu, 15 Jun 2023 12:13:56 +0200 Subject: [PATCH] Swapped allocators --- src/main.zig | 8 ++++---- src/physics.zig | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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) ) {