Skip to content

Commit

Permalink
limit total concurrent enemies to 10
Browse files Browse the repository at this point in the history
  • Loading branch information
thombruce committed Nov 18, 2023
1 parent c7e446c commit 14a15ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Spawn enemies at random distance and direction from player
- Limit total concurrent enemies to 10
- Decrease static orbit scale (planets are now closer)
- Clamp orbit distance (prevents Moon orbiting inside of Earth sprite)
- Indicators spawn on update allowing new entities to be pointed to
Expand Down
3 changes: 2 additions & 1 deletion src/ships/enemy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ pub(crate) fn spawn_enemies(
sprites: Res<SpriteAssets>,
mut spawn_timer: ResMut<SpawnTimer>,
player_position: Query<&Transform, With<Player>>,
enemies: Query<&Enemy>,
) {
// tick the timer
spawn_timer.0.tick(time.delta());

if spawn_timer.0.finished() {
if spawn_timer.0.finished() && enemies.iter().count() < 10 {
let Ok(from) = player_position.get_single() else {
return;
};
Expand Down

0 comments on commit 14a15ef

Please sign in to comment.