use bevy::prelude::*; use bevy::ecs::system::ParamSet; use std::time::Duration; use crate::components::{Bullet, Captured, Enemy, Invincible, Player}; use crate::constants::{ BULLET_SIZE, PLAYER_ENEMY_COLLISION_THRESHOLD, PLAYER_INVINCIBILITY_DURATION, PLAYER_SIZE, PLAYER_SPEED, WINDOW_HEIGHT, WINDOW_WIDTH, }; use crate::game_state::AppState; use crate::resources::{PlayerLives, PlayerRespawnTimer}; use crate::systems::spawn_explosion; // Helper to spawn player (used in setup and respawn) pub fn spawn_player_ship(commands: &mut Commands) { commands.spawn(( Sprite { color: Color::srgb(0.0, 0.5, 1.0), custom_size: Some(PLAYER_SIZE), ..default() }, Transform::from_translation(Vec3::new( 0.0, -WINDOW_HEIGHT / 2.0 + PLAYER_SIZE.y / 2.0 + 20.0, 0.0, )), Player { speed: PLAYER_SPEED, shoot_cooldown: Timer::new(Duration::from_secs_f32(0.3), TimerMode::Once), }, // Player starts invincible for a short time Invincible { timer: Timer::new( Duration::from_secs_f32(PLAYER_INVINCIBILITY_DURATION), TimerMode::Once, ), }, )); println!("Player spawned!"); } pub fn move_player( keyboard_input: Res>, mut query: Query<(&mut Transform, &Player), Without>, // Don't move captured players with controls time: Res