Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
Harald Hoyer 2025-04-11 10:43:25 +02:00
parent ef055fe3c5
commit 3dbfb9dac1
11 changed files with 1085 additions and 867 deletions

33
src/constants.rs Normal file
View file

@ -0,0 +1,33 @@
use bevy::math::Vec2;
// --- Constants ---
pub const WINDOW_WIDTH: f32 = 600.0;
pub const WINDOW_HEIGHT: f32 = 800.0;
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 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
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
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;