diff options
| author | iamcheeseman <[hidden email]> | 2026-01-17 20:43:31 -0500 |
|---|---|---|
| committer | iamcheeseman <[hidden email]> | 2026-01-17 20:43:31 -0500 |
| commit | dbe4c645e08fccb89f7bc1988f7be5c2ea246b31 (patch) | |
| tree | 9aed80632dacab389d5e1887b289d1834c184cc7 /src/phys/world.odin | |
| parent | a48cdcab8a483ac9c8524cc7fd1613f0d90cf4d4 (diff) | |
player now only applies a force to verlet
Diffstat (limited to 'src/phys/world.odin')
| -rw-r--r-- | src/phys/world.odin | 35 |
1 files changed, 17 insertions, 18 deletions
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} } } } |
