aboutsummaryrefslogtreecommitdiff
path: root/src/phys
diff options
context:
space:
mode:
authorXander Swan <[hidden email]>2025-12-23 21:35:30 -0500
committerXander Swan <[hidden email]>2025-12-23 21:35:30 -0500
commit1754937f0721f304f742575e9a27fc7ba10d8374 (patch)
treedf439bfd9733d9553ce867df6f69e5348161801c /src/phys
parent673c84b1e56f65bcda448b2304e98ff4831100fd (diff)
Add temp tile collisions
Diffstat (limited to 'src/phys')
-rw-r--r--src/phys/body.odin4
-rw-r--r--src/phys/world.odin12
2 files changed, 11 insertions, 5 deletions
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
}
}