aboutsummaryrefslogtreecommitdiff
path: root/src/muntik.odin
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-03-06 12:24:33 -0500
committeriamcheeseman <[email protected]>2026-03-06 12:24:33 -0500
commit0e799485ce4d67dc78da5dd41cbebc8b127bfcab (patch)
tree8c80617dbb6b4d1ca4d559e881efd7cd36c14c6e /src/muntik.odin
parent69bfcb3c5fec6957e00264d24990dd2f1263cd50 (diff)
death to the muntik
Diffstat (limited to 'src/muntik.odin')
-rw-r--r--src/muntik.odin22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/muntik.odin b/src/muntik.odin
index 566befc..9214cad 100644
--- a/src/muntik.odin
+++ b/src/muntik.odin
@@ -9,7 +9,6 @@ import "fw"
import "phys"
muntik_stats := Enemy_Stats{
- iframes = 0.2,
max_health = 5,
}
@@ -40,6 +39,7 @@ make_muntik :: proc(pos: Vec2, direction: f32) -> (int, ^Muntik) {
body,
)
+ muntik.ai = .Muntik
muntik.walk_dir = direction
return muntik.handle, muntik
@@ -52,20 +52,12 @@ update_muntik :: proc(e: ^Enemy, dt: f32) {
}
vel := phys.get_velocity(m.body)
- vel.x = m.walk_dir * MUNTIK_SPEED
+ vel.x = dt_lerp(vel.x, m.walk_dir * MUNTIK_SPEED, 20)
vel.y = math.min(vel.y + GRAVITY * dt, TERMINAL_VELOCITY)
phys.set_velocity(m.body, vel)
- phys.update_body(m.body)
-
pos := phys.get_position(m.body)
- m.sprite.pos = pos
- m.sprite.scale.x = -m.walk_dir
-
- set_sprite_active_tag(&m.sprite, "walk")
- update_sprite(&m.sprite, dt)
-
turnaround_rc_start := Vec2{pos.x + m.walk_dir * 4, pos.y}
turnaround_rc := phys.make_raycast(
turnaround_rc_start,
@@ -84,7 +76,15 @@ update_muntik :: proc(e: ^Enemy, dt: f32) {
}
}
- if !phys.is_colliding(turnaround_rc) {
+ if !phys.is_colliding(turnaround_rc) ||
+ .Horizontal in phys.get_collisions(m.body) {
m.walk_dir *= -1
}
+
+ m.sprite.scale.x = -m.walk_dir
+ if f32(fw.get_time()) - m.hit_timestamp < 0.1 {
+ set_sprite_active_tag(&m.sprite, "hurt")
+ } else {
+ set_sprite_active_tag(&m.sprite, "walk")
+ }
}