diff options
| author | Xander Swan <[hidden email]> | 2025-12-23 21:35:30 -0500 |
|---|---|---|
| committer | Xander Swan <[hidden email]> | 2025-12-23 21:35:30 -0500 |
| commit | 1754937f0721f304f742575e9a27fc7ba10d8374 (patch) | |
| tree | df439bfd9733d9553ce867df6f69e5348161801c /src/phys/world.odin | |
| parent | 673c84b1e56f65bcda448b2304e98ff4831100fd (diff) | |
Add temp tile collisions
Diffstat (limited to 'src/phys/world.odin')
| -rw-r--r-- | src/phys/world.odin | 12 |
1 files changed, 9 insertions, 3 deletions
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 } } |
