refactor: improve code formatting and readability in components and resources

This commit is contained in:
Harald Hoyer 2025-04-15 12:28:17 +02:00
parent 4727c370d2
commit 9aad8dd130
2 changed files with 21 additions and 12 deletions

View file

@ -31,8 +31,10 @@ impl Default for FormationLayout {
for i in 0..crate::constants::FORMATION_ENEMY_COUNT { for i in 0..crate::constants::FORMATION_ENEMY_COUNT {
let row = i / crate::constants::FORMATION_COLS; let row = i / crate::constants::FORMATION_COLS;
let col = i % crate::constants::FORMATION_COLS; let col = i % crate::constants::FORMATION_COLS;
let target_x = (col as f32 - (crate::constants::FORMATION_COLS as f32 - 1.0) / 2.0) * crate::constants::FORMATION_X_SPACING; let target_x = (col as f32 - (crate::constants::FORMATION_COLS as f32 - 1.0) / 2.0)
let target_y = crate::constants::FORMATION_BASE_Y - (row as f32 * crate::constants::FORMATION_Y_SPACING); * crate::constants::FORMATION_X_SPACING;
let target_y = crate::constants::FORMATION_BASE_Y
- (row as f32 * crate::constants::FORMATION_Y_SPACING);
positions.push(Vec3::new(target_x, target_y, 0.0)); positions.push(Vec3::new(target_x, target_y, 0.0));
} }
FormationLayout { FormationLayout {
@ -81,9 +83,16 @@ impl Default for StageConfigurations {
let count = 16; // Example: Fewer enemies in a circle let count = 16; // Example: Fewer enemies in a circle
for i in 0..count { for i in 0..count {
let angle = (i as f32 / count as f32) * 2.0 * std::f32::consts::PI; let angle = (i as f32 / count as f32) * 2.0 * std::f32::consts::PI;
positions.push(Vec3::new(angle.cos() * radius, center_y + angle.sin() * radius, 0.0)); positions.push(Vec3::new(
angle.cos() * radius,
center_y + angle.sin() * radius,
0.0,
));
}
FormationLayout {
name: "Circle".to_string(),
positions,
} }
FormationLayout { name: "Circle".to_string(), positions }
}; };
let stage2 = StageConfig { let stage2 = StageConfig {
formation_layout: stage2_layout, formation_layout: stage2_layout,