aboutsummaryrefslogtreecommitdiff
path: root/src/bullet.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/bullet.odin')
-rw-r--r--src/bullet.odin19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/bullet.odin b/src/bullet.odin
index 181147b..457ec9c 100644
--- a/src/bullet.odin
+++ b/src/bullet.odin
@@ -74,10 +74,27 @@ update_bullets :: proc(dt: f32) {
b.body,
linalg.lerp(b.vel, Vec2{0, 0}, 1 - b.lifetime / b.lifetime_max),
)
+
+ pos := phys.get_position(b.body)
- b.sprite.pos = phys.get_position(b.body)
+ b.sprite.pos = pos
b.sprite.scale.x = math.max(b.lifetime / b.lifetime_max, 0.1)
+
+ collisions := phys.get_colliding_bodies(b.body)
+ defer delete(collisions)
+
+ for body in collisions {
+ layers := phys.get_layers(body)
+ if .Enemy in layers {
+ enemy := transmute(^Enemy)phys.get_udata(body)
+
+ if enemy.health > 0 {
+ enemy_take_damage(enemy, 1, linalg.normalize(b.vel) * 100)
+ delete_bullet(b.handle)
+ }
+ }
+ }
}
}