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,7 +14,10 @@ pub struct AsteroidPlugin;
impl Plugin for AsteroidPlugin {
fn build(&self, app: &mut App) {
app.add_plugins((title_screen::GameMenuPlugin, preparation_widget::preparation_widget_plugin))
app.add_plugins((
title_screen::GameMenuPlugin,
preparation_widget::preparation_widget_plugin,
))
.insert_resource(ClearColor(BACKGROUND_COLOR))
.insert_resource(WorldSize {
width: WINDOW_SIZE.x,
@@ -24,10 +27,7 @@ impl Plugin for AsteroidPlugin {
.register_type::<Lives>()
.insert_resource(Score(0))
.add_systems(Startup, spawn_camera)
.add_systems(
OnEnter(GameState::Playing),
(spawn_player, spawn_ui),
)
.add_systems(OnEnter(GameState::Playing), (spawn_player, spawn_ui))
.add_systems(
FixedUpdate,
(input_ship_thruster, input_ship_rotation, wrap_entities)

View File

@@ -1,11 +1,17 @@
use bevy::prelude::*;
use bevy::{
color::palettes::css::{BLACK, GREEN, LIGHT_BLUE, RED},
prelude::*,
};
use crate::GameState;
pub fn preparation_widget_plugin(app: &mut App) {
app.add_systems(OnEnter(GameState::GetReady), spawn_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

View File

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