Death detection
This commit is contained in:
parent
abb0198a2b
commit
5ea5d9e2de
2 changed files with 21 additions and 5 deletions
|
|
@ -30,7 +30,7 @@ pub fn spawn_enemy(commands: &mut Commands, sprite: Handle<Image>, at: Vec2) {
|
|||
},
|
||||
Gun::new(2, f32::to_radians(15.), 0.2),
|
||||
Collider::new(8.),
|
||||
Velocity::moving(256., f32::to_radians(360.)),
|
||||
Velocity::moving(256., f32::to_radians(180.)),
|
||||
Sprite::from(sprite),
|
||||
Transform::from_xyz(at.x, at.y, 0.),
|
||||
Damagable::new(100),
|
||||
|
|
@ -77,17 +77,18 @@ pub fn enemy_ai_system(
|
|||
if distance_to_player <= enemy.return_radius * enemy.return_radius {
|
||||
enemy_velocity.linear_speed = enemy_velocity.max_linear_speed;
|
||||
enemy.state = EnemyState::Distancing;
|
||||
gun.shoot = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
EnemyState::Distancing => {
|
||||
if distance_to_player > enemy.return_radius * enemy.return_radius {
|
||||
enemy.state = EnemyState::Approaching;
|
||||
gun.shoot = false;
|
||||
continue;
|
||||
}
|
||||
if direction.angle_between(dir_to_player) > f32::to_radians(90.) {
|
||||
enemy_velocity.rotation_speed = 0.;
|
||||
gun.shoot = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue