cargo fmt

main
Elijah Voigt 2 months ago
parent 666d8f52b6
commit 583b7a41c7

@ -87,10 +87,7 @@ fn main() {
sync_resource_to_ui::<Deaths>.run_if(resource_changed::<Deaths>), sync_resource_to_ui::<Deaths>.run_if(resource_changed::<Deaths>),
sync_resource_to_ui::<RewindFrames>.run_if(resource_changed::<RewindFrames>), sync_resource_to_ui::<RewindFrames>.run_if(resource_changed::<RewindFrames>),
), ),
( (update_tooltip, debug_trail).run_if(in_state(DebuggingState::On)),
update_tooltip,
debug_trail,
).run_if(in_state(DebuggingState::On)),
// TODO: Add run_if to this system // TODO: Add run_if to this system
update_batch_position.run_if(any_component_changed::<Batch>), update_batch_position.run_if(any_component_changed::<Batch>),
move_batches.run_if(on_event::<CollisionStarted>), move_batches.run_if(on_event::<CollisionStarted>),
@ -143,10 +140,7 @@ struct Tape {
rotations: Vec<Rotation>, rotations: Vec<Rotation>,
} }
fn init_bird( fn init_bird(mut commands: Commands, bird_assets: Res<BirdAssets>) {
mut commands: Commands,
bird_assets: Res<BirdAssets>,
) {
let name = Name::new("bird"); let name = Name::new("bird");
let t = Transform::from_xyz(0.0, 0.0, 0.0).with_scale(Vec3::splat(50.0)); let t = Transform::from_xyz(0.0, 0.0, 0.0).with_scale(Vec3::splat(50.0));
@ -534,8 +528,7 @@ fn init_ui(mut commands: Commands) {
next.set(PlayerState::Alive); next.set(PlayerState::Alive);
} }
commands commands.spawn((
.spawn((
Node { Node {
align_self: AlignSelf::Center, align_self: AlignSelf::Center,
justify_self: JustifySelf::Center, justify_self: JustifySelf::Center,
@ -566,7 +559,12 @@ fn init_ui(mut commands: Commands) {
.observe(end_rewind); .observe(end_rewind);
parent parent
.spawn((Node { ..default() }, Button, FlapButton, children![Text::new("Flap!"),])) .spawn((
Node { ..default() },
Button,
FlapButton,
children![Text::new("Flap!"),],
))
.observe(flap_button); .observe(flap_button);
}); });
@ -637,7 +635,10 @@ fn flap(
// Play flap sfx // Play flap sfx
commands.spawn(( commands.spawn((
AudioPlayer::new(server.load("flappy/bonk.ogg")), AudioPlayer::new(server.load("flappy/bonk.ogg")),
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() }, PlaybackSettings {
mode: PlaybackMode::Despawn,
..default()
},
BonkSfx, BonkSfx,
)); ));
} }
@ -795,7 +796,10 @@ fn detect_dead(
// Play bonk sfx // Play bonk sfx
commands.spawn(( commands.spawn((
AudioPlayer::new(server.load("flappy/flap.ogg")), AudioPlayer::new(server.load("flappy/flap.ogg")),
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() }, PlaybackSettings {
mode: PlaybackMode::Despawn,
..default()
},
FlapSfx, FlapSfx,
)); ));
} }
@ -927,7 +931,7 @@ fn move_batches(
} else if hitboxes.contains(*a) { } else if hitboxes.contains(*a) {
*a *a
} else { } else {
return return;
} }
}; };
@ -999,21 +1003,18 @@ fn debug_trail(
}) })
} }
fn start_rewinding( fn start_rewinding(server: ResMut<AssetServer>, mut commands: Commands) {
server: ResMut<AssetServer>,
mut commands: Commands,
) {
commands.spawn(( commands.spawn((
AudioPlayer::new(server.load("flappy/rewind-start.ogg")), AudioPlayer::new(server.load("flappy/rewind-start.ogg")),
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() }, PlaybackSettings {
mode: PlaybackMode::Despawn,
..default()
},
RewindSfx, RewindSfx,
)); ));
} }
fn shimmer_button<T: Component>( fn shimmer_button<T: Component>(mut bg: Single<&mut BackgroundColor, With<T>>, time: Res<Time>) {
mut bg: Single<&mut BackgroundColor, With<T>>,
time: Res<Time>,
) {
let t = time.elapsed_secs(); let t = time.elapsed_secs();
let period = 3.0; let period = 3.0;
let r = (((t / period) % 1.0) * std::f32::consts::PI).cos(); let r = (((t / period) % 1.0) * std::f32::consts::PI).cos();
@ -1022,8 +1023,6 @@ fn shimmer_button<T: Component>(
bg.0 = Srgba::rgb(r, g, b).into(); bg.0 = Srgba::rgb(r, g, b).into();
} }
fn reset_button<T: Component>( fn reset_button<T: Component>(mut bg: Single<&mut BackgroundColor, With<T>>) {
mut bg: Single<&mut BackgroundColor, With<T>>,
) {
bg.0 = WHITE.into(); bg.0 = WHITE.into();
} }

@ -11,9 +11,9 @@ mod ui;
mod version; mod version;
// Rust stdlib // Rust stdlib
pub use std::collections::VecDeque;
pub use std::f32::consts::PI; pub use std::f32::consts::PI;
pub use std::fmt::Display; pub use std::fmt::Display;
pub use std::collections::VecDeque;
// Community libraries // Community libraries
pub use bevy::{ pub use bevy::{

Loading…
Cancel
Save