make enemy move
This commit is contained in:
+12
-1
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user