autoformat

This commit is contained in:
2025-07-27 12:57:56 -05:00
parent a7d54c9192
commit eb50655671
3 changed files with 43 additions and 40 deletions

View File

@@ -14,30 +14,30 @@ pub struct AsteroidPlugin;
impl Plugin for AsteroidPlugin { impl Plugin for AsteroidPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_plugins((title_screen::GameMenuPlugin, preparation_widget::preparation_widget_plugin)) app.add_plugins((
.insert_resource(ClearColor(BACKGROUND_COLOR)) title_screen::GameMenuPlugin,
.insert_resource(WorldSize { preparation_widget::preparation_widget_plugin,
width: WINDOW_SIZE.x, ))
height: WINDOW_SIZE.y, .insert_resource(ClearColor(BACKGROUND_COLOR))
}) .insert_resource(WorldSize {
.insert_resource(Lives(3)) width: WINDOW_SIZE.x,
.register_type::<Lives>() height: WINDOW_SIZE.y,
.insert_resource(Score(0)) })
.add_systems(Startup, spawn_camera) .insert_resource(Lives(3))
.add_systems( .register_type::<Lives>()
OnEnter(GameState::Playing), .insert_resource(Score(0))
(spawn_player, spawn_ui), .add_systems(Startup, spawn_camera)
) .add_systems(OnEnter(GameState::Playing), (spawn_player, spawn_ui))
.add_systems( .add_systems(
FixedUpdate, FixedUpdate,
(input_ship_thruster, input_ship_rotation, wrap_entities) (input_ship_thruster, input_ship_rotation, wrap_entities)
.run_if(in_state(GameState::Playing)), .run_if(in_state(GameState::Playing)),
) )
.add_systems( .add_systems(
FixedPostUpdate, FixedPostUpdate,
(integrate_velocity, update_positions, apply_rotation_to_mesh) (integrate_velocity, update_positions, apply_rotation_to_mesh)
.run_if(in_state(GameState::Playing)), .run_if(in_state(GameState::Playing)),
); );
app.insert_state(GameState::TitleScreen); app.insert_state(GameState::TitleScreen);
} }
} }

View File

@@ -1,11 +1,17 @@
use bevy::prelude::*; use bevy::{
color::palettes::css::{BLACK, GREEN, LIGHT_BLUE, RED},
prelude::*,
};
use crate::GameState; use crate::GameState;
pub fn preparation_widget_plugin(app: &mut App) { pub fn preparation_widget_plugin(app: &mut App) {
app.add_systems(OnEnter(GameState::GetReady), spawn_get_ready) app.add_systems(OnEnter(GameState::GetReady), spawn_get_ready)
.add_systems(OnExit(GameState::GetReady), despawn_get_ready) .add_systems(OnExit(GameState::GetReady), despawn_get_ready)
.add_systems(Update, (animate_get_ready_widget).run_if(in_state(GameState::GetReady))); .add_systems(
Update,
(animate_get_ready_widget).run_if(in_state(GameState::GetReady)),
);
} }
/// Marker component for things on the get-ready indicator /// Marker component for things on the get-ready indicator
@@ -65,6 +71,6 @@ fn despawn_get_ready(mut commands: Commands, to_despawn: Query<Entity, With<OnRe
} }
} }
fn animate_get_ready_widget(){ fn animate_get_ready_widget() {
todo!(); todo!();
} }

View File

@@ -8,7 +8,10 @@ impl Plugin for GameMenuPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(OnEnter(GameState::TitleScreen), spawn_menu) app.add_systems(OnEnter(GameState::TitleScreen), spawn_menu)
.add_systems(OnExit(GameState::TitleScreen), despawn_menu) .add_systems(OnExit(GameState::TitleScreen), despawn_menu)
.add_systems(Update, handle_spacebar.run_if(in_state(GameState::TitleScreen))); .add_systems(
Update,
handle_spacebar.run_if(in_state(GameState::TitleScreen)),
);
} }
} }
@@ -38,20 +41,14 @@ fn spawn_menu(mut commands: Commands) {
}); });
} }
fn despawn_menu( fn despawn_menu(mut commands: Commands, to_despawn: Query<Entity, With<TitleUI>>) {
mut commands: Commands,
to_despawn: Query<Entity, With<TitleUI>>,
) {
for entity in &to_despawn { for entity in &to_despawn {
commands.entity(entity).despawn(); commands.entity(entity).despawn();
} }
} }
fn handle_spacebar( fn handle_spacebar(input: Res<ButtonInput<KeyCode>>, mut game_state: ResMut<NextState<GameState>>) {
input: Res<ButtonInput<KeyCode>>,
mut game_state: ResMut<NextState<GameState>>,
) {
if input.just_pressed(KeyCode::Space) { if input.just_pressed(KeyCode::Space) {
game_state.set(GameState::Playing); game_state.set(GameState::GetReady);
} }
} }