diff options
| author | iamcheeseman <[email protected]> | 2026-03-03 21:13:32 -0500 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-03-03 21:13:32 -0500 |
| commit | 86f95e0737ba082625c22d40057e66499cbc8ac1 (patch) | |
| tree | c86336bf0a21b7740d8b5416424b30c4bb3eee9e /src/muntik.odin | |
| parent | 11d72700ad9afd1d23bdae730edf5b160e99fde4 (diff) | |
Health and dying
Diffstat (limited to 'src/muntik.odin')
| -rw-r--r-- | src/muntik.odin | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/muntik.odin b/src/muntik.odin index 023174c..0612fd6 100644 --- a/src/muntik.odin +++ b/src/muntik.odin @@ -1,6 +1,8 @@ package demonchime import "core:math" +import "core:math/linalg" +import "core:log" import hm "core:container/handle_map" import "fw" @@ -24,6 +26,7 @@ make_muntik :: proc(pos: Vec2, direction: f32) -> (Handle, ^Muntik) { body := phys.make_body( phys.Rect{-sprite.offset, {14, 9}}, layers = {.Enemy}, + mask = {.Player, .Hard}, ) phys.set_position(body, pos) @@ -59,6 +62,18 @@ update_muntiks :: proc(dt: f32) { turnaround_rc_start + {0, 16}, ) + collisions := phys.get_colliding_bodies(m.body) + defer delete(collisions) + + for body in collisions { + layers := phys.get_layers(body) + if .Player in layers { + bpos := phys.get_position(body) + dir := linalg.normalize0(bpos - pos) * 500 + player_take_damage(MUNTIK_DAMAGE, dir) + } + } + if !phys.is_colliding(turnaround_rc) { m.walk_dir *= -1 } |
