aboutsummaryrefslogtreecommitdiff
path: root/src/phys
diff options
context:
space:
mode:
Diffstat (limited to 'src/phys')
-rw-r--r--src/phys/body.odin2
-rw-r--r--src/phys/world.odin13
2 files changed, 11 insertions, 4 deletions
diff --git a/src/phys/body.odin b/src/phys/body.odin
index d568186..93d8623 100644
--- a/src/phys/body.odin
+++ b/src/phys/body.odin
@@ -13,6 +13,8 @@ Layer :: enum (u16) {
SOFT, // soft collisions; push away other bodies with a force
ENEMY, // enemy hitboxes
PLAYER, // player hitboxes
+ ENEMY_PROJECTILE,
+ PLAYER_PROJECTILE,
}
Collision_Type :: enum (u8) {
diff --git a/src/phys/world.odin b/src/phys/world.odin
index 5bbfcbd..7a56990 100644
--- a/src/phys/world.odin
+++ b/src/phys/world.odin
@@ -33,9 +33,9 @@ _hash_bin :: proc(x: i32, y: i32) -> u32 {
@(private = "file")
_world_to_bin :: proc(point: Vec2) -> (i32, i32) {
- return i32(
- math.floor(point.x / BIN_SIZE),
- ), i32(math.floor(point.y / BIN_SIZE))
+ return \
+ i32(math.floor(point.x / BIN_SIZE)),
+ i32(math.floor(point.y / BIN_SIZE))
}
@(private = "file")
@@ -85,8 +85,9 @@ _remove_from_bins :: proc(b: Body) {
last := pop(bin)
if last != b.handle {
// log.debug(last, b.handle)
- last_body := get_body(last)
bin[b.bin_idx] = last
+
+ last_body := get_body(last)
last_body.bin_idx = b.bin_idx
}
}
@@ -192,6 +193,10 @@ update_body :: proc(h: Body_Handle) {
c := get_body(c_h)
+ if b.mask & c.layers == {} {
+ continue
+ }
+
c_rect := c.rect
c_rect.start += c.pos