From dbe4c645e08fccb89f7bc1988f7be5c2ea246b31 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Sat, 17 Jan 2026 20:43:31 -0500 Subject: player now only applies a force to verlet --- src/phys/world.odin | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/phys/world.odin') diff --git a/src/phys/world.odin b/src/phys/world.odin index 0f1451c..70309b5 100644 --- a/src/phys/world.odin +++ b/src/phys/world.odin @@ -40,8 +40,7 @@ _world_to_bin :: proc(point: Vec2) -> (i32, i32) { i32(math.floor(point.y / BIN_SIZE)) } -@(private = "file") -_get_surrounding_bins :: proc( +get_surrounding_bins :: proc( pos: Vec2, allocator := context.temp_allocator, ) -> []^[dynamic]Body_Handle { @@ -169,7 +168,7 @@ get_colliding_bodies :: proc( rect := b.rect rect.start += b.pos - bin_list := _get_surrounding_bins(rect.start) + bin_list := get_surrounding_bins(rect.start) for bin in bin_list { for c_h in bin { @@ -212,7 +211,7 @@ update_body :: proc(h: Body_Handle) { res_rect := b.rect res_rect.start += b.pos + b.vel * dt * p - bin_list := _get_surrounding_bins(res_rect.start) + bin_list := get_surrounding_bins(res_rect.start) for bin in bin_list { for c_h in bin { @@ -234,20 +233,20 @@ update_body :: proc(h: Body_Handle) { if b.vel.y > 0 { res_pos.y = c_rect.start.y - b.rect.size.y - b.rect.start.y b.collisions += {.Down} - } else { - res_pos.y = c_rect.start.y + c_rect.size.y - b.rect.start.y - b.collisions += {.Up} - } - b.collisions += {.Vertical} - } else if aabb_vert(rect, c.rect) { - if b.vel.x > 0 { - res_pos.x = c_rect.start.x - b.rect.size.x - b.rect.start.x - b.collisions += {.Left} - } else { - res_pos.x = c_rect.start.x + c_rect.size.x - b.rect.start.x - b.collisions += {.Right} - } - b.collisions += {.Horizontal} + } else { + res_pos.y = c_rect.start.y + c_rect.size.y - b.rect.start.y + b.collisions += {.Up} + } + b.collisions += {.Vertical} + } else if aabb_vert(rect, c.rect) { + if b.vel.x > 0 { + res_pos.x = c_rect.start.x - b.rect.size.x - b.rect.start.x + b.collisions += {.Left} + } else { + res_pos.x = c_rect.start.x + c_rect.size.x - b.rect.start.x + b.collisions += {.Right} + } + b.collisions += {.Horizontal} } } } -- cgit v1.3-2-g0d8e