diff options
| author | iamcheeseman <[email protected]> | 2026-03-06 12:30:31 -0500 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-03-06 12:30:31 -0500 |
| commit | f91cea9dd4de39f75b14aee61c96c8cc929059e3 (patch) | |
| tree | 40770cfb6b49f550a59c80aacc18b475ec606f5a /src/muntik.odin | |
| parent | 0e799485ce4d67dc78da5dd41cbebc8b127bfcab (diff) | |
muntik will now turn away from any challenge
Diffstat (limited to 'src/muntik.odin')
| -rw-r--r-- | src/muntik.odin | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/muntik.odin b/src/muntik.odin index 9214cad..1464d91 100644 --- a/src/muntik.odin +++ b/src/muntik.odin @@ -22,7 +22,7 @@ make_muntik :: proc(pos: Vec2, direction: f32) -> (int, ^Muntik) { init_sprite(&sprite, .Muntik) sprite.offset = { f32(sprite.width / 2), - f32(sprite.height), + f32(sprite.height / 2), } body := phys.make_body( @@ -58,12 +58,6 @@ update_muntik :: proc(e: ^Enemy, dt: f32) { pos := phys.get_position(m.body) - turnaround_rc_start := Vec2{pos.x + m.walk_dir * 4, pos.y} - turnaround_rc := phys.make_raycast( - turnaround_rc_start, - turnaround_rc_start + {0, 16}, - ) - collisions := phys.get_colliding_bodies(m.body) defer delete(collisions) @@ -76,8 +70,20 @@ update_muntik :: proc(e: ^Enemy, dt: f32) { } } - if !phys.is_colliding(turnaround_rc) || - .Horizontal in phys.get_collisions(m.body) { + ground_rc_start := Vec2{pos.x + m.walk_dir * 4, pos.y} + ground_rc := phys.make_raycast( + ground_rc_start, + ground_rc_start + {0, 16}, + ) + + wall_rc_start := pos + wall_rc := phys.make_raycast( + wall_rc_start, + wall_rc_start + {m.walk_dir * 8, 0}, + ) + + if !phys.is_colliding(ground_rc) || + phys.is_colliding(wall_rc) { m.walk_dir *= -1 } |
