|
|
|
|
@ -87,10 +87,7 @@ fn main() {
|
|
|
|
|
sync_resource_to_ui::<Deaths>.run_if(resource_changed::<Deaths>),
|
|
|
|
|
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
|
|
|
|
|
update_batch_position.run_if(any_component_changed::<Batch>),
|
|
|
|
|
move_batches.run_if(on_event::<CollisionStarted>),
|
|
|
|
|
@ -143,10 +140,7 @@ struct Tape {
|
|
|
|
|
rotations: Vec<Rotation>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn init_bird(
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
bird_assets: Res<BirdAssets>,
|
|
|
|
|
) {
|
|
|
|
|
fn init_bird(mut commands: Commands, bird_assets: Res<BirdAssets>) {
|
|
|
|
|
let name = Name::new("bird");
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commands
|
|
|
|
|
.spawn((
|
|
|
|
|
commands.spawn((
|
|
|
|
|
Node {
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
@ -566,7 +559,12 @@ fn init_ui(mut commands: Commands) {
|
|
|
|
|
.observe(end_rewind);
|
|
|
|
|
|
|
|
|
|
parent
|
|
|
|
|
.spawn((Node { ..default() }, Button, FlapButton, children![Text::new("Flap!"),]))
|
|
|
|
|
.spawn((
|
|
|
|
|
Node { ..default() },
|
|
|
|
|
Button,
|
|
|
|
|
FlapButton,
|
|
|
|
|
children![Text::new("Flap!"),],
|
|
|
|
|
))
|
|
|
|
|
.observe(flap_button);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@ -637,7 +635,10 @@ fn flap(
|
|
|
|
|
// Play flap sfx
|
|
|
|
|
commands.spawn((
|
|
|
|
|
AudioPlayer::new(server.load("flappy/bonk.ogg")),
|
|
|
|
|
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() },
|
|
|
|
|
PlaybackSettings {
|
|
|
|
|
mode: PlaybackMode::Despawn,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
BonkSfx,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
@ -795,7 +796,10 @@ fn detect_dead(
|
|
|
|
|
// Play bonk sfx
|
|
|
|
|
commands.spawn((
|
|
|
|
|
AudioPlayer::new(server.load("flappy/flap.ogg")),
|
|
|
|
|
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() },
|
|
|
|
|
PlaybackSettings {
|
|
|
|
|
mode: PlaybackMode::Despawn,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
FlapSfx,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
@ -927,7 +931,7 @@ fn move_batches(
|
|
|
|
|
} else if hitboxes.contains(*a) {
|
|
|
|
|
*a
|
|
|
|
|
} else {
|
|
|
|
|
return
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -999,21 +1003,18 @@ fn debug_trail(
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn start_rewinding(
|
|
|
|
|
server: ResMut<AssetServer>,
|
|
|
|
|
mut commands: Commands,
|
|
|
|
|
) {
|
|
|
|
|
fn start_rewinding(server: ResMut<AssetServer>, mut commands: Commands) {
|
|
|
|
|
commands.spawn((
|
|
|
|
|
AudioPlayer::new(server.load("flappy/rewind-start.ogg")),
|
|
|
|
|
PlaybackSettings { mode: PlaybackMode::Despawn, ..default() },
|
|
|
|
|
PlaybackSettings {
|
|
|
|
|
mode: PlaybackMode::Despawn,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
RewindSfx,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn shimmer_button<T: Component>(
|
|
|
|
|
mut bg: Single<&mut BackgroundColor, With<T>>,
|
|
|
|
|
time: Res<Time>,
|
|
|
|
|
) {
|
|
|
|
|
fn shimmer_button<T: Component>(mut bg: Single<&mut BackgroundColor, With<T>>, time: Res<Time>) {
|
|
|
|
|
let t = time.elapsed_secs();
|
|
|
|
|
let period = 3.0;
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn reset_button<T: Component>(
|
|
|
|
|
mut bg: Single<&mut BackgroundColor, With<T>>,
|
|
|
|
|
) {
|
|
|
|
|
fn reset_button<T: Component>(mut bg: Single<&mut BackgroundColor, With<T>>) {
|
|
|
|
|
bg.0 = WHITE.into();
|
|
|
|
|
}
|
|
|
|
|
|