diff --git a/Cargo.toml b/Cargo.toml index 22e0551..a348cbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "games" version = "0.1.0" edition = "2024" +[features] +hide_debug = [] + [dependencies] thiserror = "2.0.12" diff --git a/src/base_game.rs b/src/base_game.rs index 05f493e..e7119d9 100644 --- a/src/base_game.rs +++ b/src/base_game.rs @@ -30,6 +30,7 @@ impl Plugin for BaseGamePlugin { DefaultPlugins .set(WindowPlugin { primary_window: Some(Window { + title: self.title.clone(), fit_canvas_to_parent: true, resolution: self.target_resolution.clone(), ..default() diff --git a/src/bin/flappy/main.rs b/src/bin/flappy/main.rs index 10e8f61..bf6ba65 100644 --- a/src/bin/flappy/main.rs +++ b/src/bin/flappy/main.rs @@ -326,7 +326,7 @@ fn populate_ground( Name::new("ground"), RigidBody::Static, Collider::rectangle(1.0, 0.75), - Transform::from_xyz(100.0 * (*idx) as f32, -275.0, -1.0).with_scale(Vec3::splat(100.0)), + Transform::from_xyz(100.0 * (*idx) as f32, -275.0, -1.0).with_scale(Vec3::splat(106.0)), )); } @@ -1279,7 +1279,9 @@ fn shimmer_button(mut bg: Single<&mut BackgroundColor, With>, t let chroma = 0.5; let hue = (t * 60.0) % 360.0; bg.0 = Oklcha { - lightness, chroma, hue, + lightness, + chroma, + hue, alpha: bg.0.alpha(), } .into(); diff --git a/src/debug.rs b/src/debug.rs index 153be82..4ccf598 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -120,7 +120,12 @@ fn init_debug_ui(mut commands: Commands) { flex_direction: FlexDirection::Column, ..default() }, + // When we are showing the debug button, allow this to be visible by default + #[cfg(not(feature = "hide_debug"))] DebuggingState::Off, + // Hide the "Debug Toggle" button when this feature is enabled + #[cfg(feature = "hide_debug")] + DebuggingState::On, Name::new("Debug Indicator"), GlobalZIndex(i32::MAX - 1), BorderRadius::all(Val::Px(5.0)), diff --git a/src/lib.rs b/src/lib.rs index 4877358..eb11e13 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(stmt_expr_attributes)] #![allow(ambiguous_glob_reexports)] #![allow(clippy::type_complexity)] diff --git a/src/loading.rs b/src/loading.rs index f3a43d9..28a6520 100644 --- a/src/loading.rs +++ b/src/loading.rs @@ -9,8 +9,10 @@ impl Plugin for LoadingPlugin { app.init_resource::() .init_state::() .add_systems(PreUpdate, reset_progress) + .add_systems(Startup, spawn_loading_screen) .add_systems( Update, + ( ( track_loading::, track_loading::, @@ -20,12 +22,14 @@ impl Plugin for LoadingPlugin { track_loading::, ) .run_if(in_state(LoadingState::Active)), + toggle_state_visibility::.run_if(state_changed::), + ) ) .add_systems(PostUpdate, check_progress); } } -#[derive(States, Clone, PartialEq, Eq, Hash, Debug, Default)] +#[derive(States, Clone, PartialEq, Eq, Hash, Debug, Default, Component)] pub enum LoadingState { #[default] Active, @@ -36,6 +40,23 @@ pub enum LoadingState { #[derive(Resource, Default)] struct TrackLoadingProgress(Vec); +fn spawn_loading_screen(mut commands: Commands) { + commands.spawn(( + Node { + align_self: AlignSelf::Center, + justify_self: JustifySelf::Center, + ..default() + }, + LoadingState::Active, + children![ + ( + TextColor(WHITE.into()), + Text::new("Credits"), + BackgroundColor(BLACK.into()) + )], + )); +} + /// At the start of the update clear progress fn reset_progress(mut progress: ResMut) { progress.0.clear()