From 1754937f0721f304f742575e9a27fc7ba10d8374 Mon Sep 17 00:00:00 2001 From: Xander Swan <[hidden email]> Date: Tue, 23 Dec 2025 21:35:30 -0500 Subject: Add temp tile collisions --- src/phys/body.odin | 4 ++-- src/phys/world.odin | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/phys') diff --git a/src/phys/body.odin b/src/phys/body.odin index 0256dee..0fe6c51 100644 --- a/src/phys/body.odin +++ b/src/phys/body.odin @@ -15,7 +15,7 @@ Layer :: enum(u16) { PLAYER, // player hitboxes } -Collision_Type :: enum(u16) { +Collision_Type :: enum(u8) { UP, DOWN, RIGHT, @@ -31,7 +31,7 @@ Body :: struct { active: bool, pos: Vec2, vel: Vec2, - collisions: bit_set[Collision_Type; u16], + collisions: bit_set[Collision_Type; u8], layers: bit_set[Layer; u16], mask: bit_set[Layer; u16], } diff --git a/src/phys/world.odin b/src/phys/world.odin index 0f03de7..8470872 100644 --- a/src/phys/world.odin +++ b/src/phys/world.odin @@ -195,15 +195,21 @@ update_body :: proc(h: Body_Handle) { b.vel.y = 0 } + set_body_position(h, res_pos) +} + +set_body_position :: proc(h: Body_Handle, new_pos: Vec2) { + b := get_body(h) + prev_bin := hash_bin(world_to_bin(b.pos + b.rect.start)) - res_bin := hash_bin(world_to_bin(res_pos + b.rect.start)) + res_bin := hash_bin(world_to_bin(new_pos + b.rect.start)) if prev_bin != res_bin { remove_from_bins(b^) - b.pos = res_pos + b.pos = new_pos add_to_bins(b^) } else { - b.pos = res_pos + b.pos = new_pos } } -- cgit v1.3-2-g0d8e