mirror of
https://github.com/IgLemp/platformer.git
synced 2024-11-24 19:22:14 +01:00
Swapped allocators
This commit is contained in:
parent
c5d1b05d8c
commit
c003155edd
@ -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);
|
||||
|
||||
|
@ -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) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user