diff --git a/CHANGELOG.md b/CHANGELOG.md index 085a1e3..b3c663e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add game score that increases when player damages or destroys an enemy +- Spawn timer; enemies will now spawn continuously ### 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 ## [0.0.25] - 2023-11-17 diff --git a/src/ships/enemy.rs b/src/ships/enemy.rs index 44acaeb..a6a6188 100644 --- a/src/ships/enemy.rs +++ b/src/ships/enemy.rs @@ -1,5 +1,6 @@ use bevy::prelude::*; use bevy_rapier2d::prelude::*; +use rand::Rng; use crate::core::resources::assets::SpriteAssets; use crate::systems::events::BulletSpawnEvent; @@ -11,6 +12,16 @@ use super::{ ship::{ship_rotation, ship_thrust, Health, Ship}, }; +pub struct SpawnTimerPlugin; +impl Plugin for SpawnTimerPlugin { + fn build(&self, app: &mut App) { + app.insert_resource(SpawnTimer(Timer::from_seconds(6.0, TimerMode::Repeating))); + } +} + +#[derive(Resource)] +pub struct SpawnTimer(pub Timer); + /// Enemy component #[derive(Component)] pub struct Enemy; @@ -69,19 +80,30 @@ pub struct Adversaries(pub Vec); // retrieval/use at a later time. /// The setup function -pub(crate) fn spawn_enemies(mut commands: Commands, sprites: Res) { - // Spawns enemy ships - for (_i, pos) in [ - (250.0 as f32, 250.0 as f32), - (-250.0 as f32, -250.0 as f32), - (-25000.0 as f32, 0.0 as f32), - (25000.0 as f32, 0.0 as f32), - (0.0 as f32, 25000.0 as f32), - (0.0 as f32, -25000.0 as f32), - ] - .iter() - .enumerate() - { +pub(crate) fn spawn_enemies( + time: Res