Add loading indicator and increase flappy bird ground square sizes

main
Elijah Voigt 2 months ago
parent 77998a5197
commit e2554bd8f7

@ -3,6 +3,9 @@ name = "games"
version = "0.1.0"
edition = "2024"
[features]
hide_debug = []
[dependencies]
thiserror = "2.0.12"

@ -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()

@ -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<T: Component>(mut bg: Single<&mut BackgroundColor, With<T>>, 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();

@ -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)),

@ -1,3 +1,4 @@
#![feature(stmt_expr_attributes)]
#![allow(ambiguous_glob_reexports)]
#![allow(clippy::type_complexity)]

@ -9,8 +9,10 @@ impl Plugin for LoadingPlugin {
app.init_resource::<TrackLoadingProgress>()
.init_state::<LoadingState>()
.add_systems(PreUpdate, reset_progress)
.add_systems(Startup, spawn_loading_screen)
.add_systems(
Update,
(
(
track_loading::<AnimationClip>,
track_loading::<AudioSource>,
@ -20,12 +22,14 @@ impl Plugin for LoadingPlugin {
track_loading::<Shader>,
)
.run_if(in_state(LoadingState::Active)),
toggle_state_visibility::<LoadingState>.run_if(state_changed::<LoadingState>),
)
)
.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<bool>);
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<TrackLoadingProgress>) {
progress.0.clear()

Loading…
Cancel
Save