diff options
| author | iamcheeseman <[email protected]> | 2026-03-06 12:24:33 -0500 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-03-06 12:24:33 -0500 |
| commit | 0e799485ce4d67dc78da5dd41cbebc8b127bfcab (patch) | |
| tree | 8c80617dbb6b4d1ca4d559e881efd7cd36c14c6e /src/bullet.odin | |
| parent | 69bfcb3c5fec6957e00264d24990dd2f1263cd50 (diff) | |
death to the muntik
Diffstat (limited to 'src/bullet.odin')
| -rw-r--r-- | src/bullet.odin | 19 |
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) + } + } + } } } |
