From 0e799485ce4d67dc78da5dd41cbebc8b127bfcab Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Fri, 6 Mar 2026 12:24:33 -0500 Subject: death to the muntik --- src/bullet.odin | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/bullet.odin') 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) + } + } + } } } -- cgit v1.3-2-g0d8e