diff --git a/src/components.rs b/src/components.rs index 0577976..6b02234 100644 --- a/src/components.rs +++ b/src/components.rs @@ -33,11 +33,20 @@ pub struct FormationTarget { pub position: Vec3, } -#[derive(Component, Clone, PartialEq)] +// Enum defining different ways an enemy can attack +#[derive(Component, Clone, Copy, PartialEq, Debug)] +pub enum AttackPattern { + SwoopDive, // Original pattern: dive towards center, then off screen + DirectDive, // Dive straight down + Kamikaze(Vec3), // Dive towards a specific target location (e.g., player's last known position) - Needs target Vec3 + // Add more patterns later (e.g., FigureEight, Looping) +} + +#[derive(Component, Clone, PartialEq, Debug)] // Added Debug derive pub enum EnemyState { - Entering, // Flying onto the screen towards formation target - InFormation, // Holding position in the formation - Attacking, // Diving towards the player + Entering, // Flying onto the screen towards formation target + InFormation, // Holding position in the formation + Attacking(AttackPattern), // Diving towards the player using a specific pattern } #[derive(Component)] diff --git a/src/enemy.rs b/src/enemy.rs index 145553d..5cacf51 100644 --- a/src/enemy.rs +++ b/src/enemy.rs @@ -2,59 +2,69 @@ use bevy::prelude::*; use std::time::Duration; use crate::components::{Enemy, EnemyBullet, EnemyState, EnemyType, FormationTarget}; -use crate::constants::{ +use crate::constants::{ // Added WINDOW_WIDTH ENEMY_BULLET_PLAYER_COLLISION_THRESHOLD, ENEMY_BULLET_SIZE, ENEMY_BULLET_SPEED, ENEMY_SHOOT_INTERVAL, ENEMY_SIZE, ENEMY_SPEED, FORMATION_BASE_Y, FORMATION_COLS, - FORMATION_ENEMY_COUNT, FORMATION_X_SPACING, FORMATION_Y_SPACING, WINDOW_HEIGHT, + FORMATION_ENEMY_COUNT, FORMATION_X_SPACING, FORMATION_Y_SPACING, WINDOW_HEIGHT, WINDOW_WIDTH, }; use crate::resources::{ AttackDiveTimer, CurrentStage, EnemySpawnTimer, FormationState, PlayerLives, - PlayerRespawnTimer, + PlayerRespawnTimer, StageConfigurations, // Make sure StageConfigurations is imported if not already }; -use crate::game_state::AppState; // Needed for check_enemy_bullet_player_collisions +use crate::game_state::AppState; pub fn spawn_enemies( mut commands: Commands, time: Res