refactor: idiomatic cleanup across the codebase
Net -311 lines (1075 → 764). Build clean, clippy clean, 8 tests pass, headless render verified. Highlights: - player.rs: bug fix in handle_captured_player — was cloning captured.timer and ticking the clone, never the real timer. Consolidated kill_player as pub(crate) helper (was duplicated across 3 sites). Switched from ParamSet to two disjoint Queries. - enemy.rs: extracted step_attacker(), spawn_beam_visual(), end_beam(), pick_pattern() helpers — move_enemies is no longer 3-deep nested matches, beam cleanup no longer duplicated. Fixed SwoopDive overshoot check (was using already-applied movement). Mid-file `use` hoisted to top. - resources.rs: added StageConfigurations::for_stage() helper (was repeated 4×); FormationState/Score/CurrentStage now Default; extracted circle_formation() helper. - stage.rs: replaced raw world: &mut World access with ordinary ResMut system params (no need — resource types are disjoint). - game_state.rs: cleanup queries collapsed via Or<…> filters; dropped dead RestartMessage cleanup from cleanup_game_entities; button colors extracted as constants. - bullet.rs: reuses kill_player; introduced GRUNT_POINTS/BOSS_POINTS with TODO referencing GAL-27. - lib.rs: init_resource::<T>() for Default-implementing resources. - Removed unused TRACTOR_BEAM_COLOR constant. - Replaced per-frame println! debug spam with targeted info!/warn!. - Stripped noise comments that restated what the code does. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b2b564f690
commit
ad2037a7a5
11 changed files with 762 additions and 1073 deletions
|
|
@ -1,60 +1,61 @@
|
|||
use bevy::math::Vec2;
|
||||
use bevy::prelude::*;
|
||||
|
||||
// --- Constants ---
|
||||
// Window
|
||||
pub const WINDOW_WIDTH: f32 = 600.0;
|
||||
pub const WINDOW_HEIGHT: f32 = 800.0;
|
||||
|
||||
// Player
|
||||
pub const PLAYER_SPEED: f32 = 300.0;
|
||||
pub const BULLET_SPEED: f32 = 500.0;
|
||||
pub const ENEMY_SPEED: f32 = 100.0;
|
||||
pub const PLAYER_SIZE: Vec2 = Vec2::new(30.0, 30.0);
|
||||
pub const STARTING_LIVES: u32 = 3;
|
||||
pub const PLAYER_RESPAWN_DELAY: f32 = 2.0;
|
||||
pub const PLAYER_INVINCIBILITY_DURATION: f32 = 2.0;
|
||||
|
||||
// Enemies
|
||||
pub const ENEMY_SPEED: f32 = 100.0;
|
||||
pub const ENEMY_SIZE: Vec2 = Vec2::new(40.0, 40.0);
|
||||
pub const BULLET_SIZE: Vec2 = Vec2::new(5.0, 15.0);
|
||||
// Player bullet
|
||||
pub const ENEMY_BULLET_SIZE: Vec2 = Vec2::new(8.0, 8.0);
|
||||
// Enemy bullet
|
||||
pub const ENEMY_BULLET_SPEED: f32 = 300.0;
|
||||
pub const ENEMY_SHOOT_INTERVAL: f32 = 1.5;
|
||||
// Formation constants
|
||||
|
||||
// Bullets
|
||||
pub const BULLET_SPEED: f32 = 500.0;
|
||||
pub const BULLET_SIZE: Vec2 = Vec2::new(5.0, 15.0);
|
||||
pub const ENEMY_BULLET_SIZE: Vec2 = Vec2::new(8.0, 8.0);
|
||||
pub const ENEMY_BULLET_SPEED: f32 = 300.0;
|
||||
|
||||
// Formation
|
||||
const FORMATION_ROWS: usize = 4;
|
||||
pub const FORMATION_COLS: usize = 8;
|
||||
pub const FORMATION_ENEMY_COUNT: usize = FORMATION_ROWS * FORMATION_COLS;
|
||||
pub const FORMATION_X_SPACING: f32 = 60.0;
|
||||
pub const FORMATION_Y_SPACING: f32 = 50.0;
|
||||
pub const FORMATION_BASE_Y: f32 = WINDOW_HEIGHT / 2.0 - 150.0;
|
||||
// Top area for formation
|
||||
pub const STARTING_LIVES: u32 = 3;
|
||||
pub const PLAYER_RESPAWN_DELAY: f32 = 2.0;
|
||||
pub const PLAYER_INVINCIBILITY_DURATION: f32 = 2.0;
|
||||
// Collision thresholds
|
||||
|
||||
// Collision thresholds (mean of half-widths)
|
||||
pub const BULLET_ENEMY_COLLISION_THRESHOLD: f32 = (BULLET_SIZE.x + ENEMY_SIZE.x) * 0.5;
|
||||
// 22.5
|
||||
pub const PLAYER_ENEMY_COLLISION_THRESHOLD: f32 = (PLAYER_SIZE.x + ENEMY_SIZE.x) * 0.5;
|
||||
// 35.0
|
||||
pub const ENEMY_BULLET_PLAYER_COLLISION_THRESHOLD: f32 =
|
||||
(ENEMY_BULLET_SIZE.x + PLAYER_SIZE.x) * 0.5;
|
||||
|
||||
// Tractor beam constants
|
||||
// Tractor beam
|
||||
pub const TRACTOR_BEAM_WIDTH: f32 = 20.0;
|
||||
pub const TRACTOR_BEAM_DURATION: f32 = 3.0;
|
||||
pub const TRACTOR_BEAM_COLOR: Color = Color::srgba(0.5, 0.0, 0.8, 0.6);
|
||||
pub const CAPTURE_DURATION: f32 = 10.0; // How long the player stays captured
|
||||
// Tractor beam visual constants
|
||||
pub const CAPTURE_DURATION: f32 = 10.0;
|
||||
pub const BEAM_GLOW_WIDTH: f32 = 40.0;
|
||||
pub const BEAM_GLOW_COLOR: Color = Color::srgba(0.3, 0.0, 0.5, 0.25);
|
||||
pub const BEAM_CORE_COLOR: Color = Color::srgba(0.7, 0.2, 1.0, 0.7);
|
||||
pub const BEAM_PULSE_FREQ: f32 = 3.0;
|
||||
pub const BEAM_PULSE_AMPLITUDE: f32 = 0.15;
|
||||
|
||||
// Starfield constants
|
||||
// Starfield
|
||||
pub const STAR_COUNT: usize = 150;
|
||||
pub const STAR_MIN_SIZE: f32 = 1.0;
|
||||
pub const STAR_MAX_SIZE: f32 = 3.0;
|
||||
pub const STAR_MIN_SPEED: f32 = 20.0;
|
||||
pub const STAR_MAX_SPEED: f32 = 100.0;
|
||||
pub const STAR_Z_DEPTH: f32 = -10.0; // Behind all game entities
|
||||
pub const STAR_Z_DEPTH: f32 = -10.0;
|
||||
|
||||
// Explosion constants
|
||||
// Explosion
|
||||
pub const EXPLOSION_DURATION: f32 = 0.4;
|
||||
pub const EXPLOSION_BASE_SIZE: Vec2 = Vec2::new(15.0, 15.0);
|
||||
pub const EXPLOSION_MAX_SIZE: Vec2 = Vec2::new(50.0, 50.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue