make enemy move

This commit is contained in:
2026-06-10 02:32:01 -07:00
parent d7ac123359
commit 85f6a286ac
5 changed files with 54 additions and 7 deletions
+12 -1
View File
@@ -4,6 +4,7 @@ Enemy :: struct {
position: Vec2,
health: int,
active: bool,
speed: f32,
}
spawn_enemy :: proc(world: ^World) {
@@ -11,8 +12,18 @@ spawn_enemy :: proc(world: ^World) {
world.enemy = Enemy {
position = world.path[0],
health = 20,
health = 40,
speed = 60,
active = true,
}
}
update_enemy :: proc(world: ^World, dt: f32) {
e := &world.enemy
if !e.active do return
if len(world.path) == 0 do return
target := world.path[len(world.path) - 1]
move_toward(&e.position, target, e.speed, dt)
}