Some jank but workable

main
Elijah Voigt 3 months ago
parent 6afc2d0b04
commit cc8fdac7c1

@ -8,8 +8,8 @@ fn main() {
}) })
.init_state::<PlayerState>() .init_state::<PlayerState>()
.add_systems(Startup, (init_bird, init_ui)) .add_systems(Startup, (init_bird, init_ui))
.add_systems(OnEnter(PlayerState::Dead), kill_bird)
.add_systems(OnEnter(PlayerState::Alive), alive_bird) .add_systems(OnEnter(PlayerState::Alive), alive_bird)
.add_systems(OnExit(PlayerState::Alive), kill_bird)
.add_systems( .add_systems(
Update, Update,
( (
@ -136,10 +136,10 @@ fn toggle_rewind(keycode: Res<ButtonInput<KeyCode>>, mut next: ResMut<NextState<
); );
if keycode.pressed(KeyCode::KeyR) { if keycode.pressed(KeyCode::KeyR) {
info!("Toggling rewind ON"); debug!("Toggling rewind ON");
next.set(PlayerState::Rewind) next.set(PlayerState::Rewind)
} else { } else {
info!("Toggling rewind OFF"); debug!("Toggling rewind OFF");
next.set(PlayerState::Alive) next.set(PlayerState::Alive)
} }
} }
@ -169,8 +169,12 @@ fn rewind(
); );
birds.iter_mut().for_each(|(mut transform, mut tape)| { birds.iter_mut().for_each(|(mut transform, mut tape)| {
transform.translation = tape.translations.pop().unwrap(); if let Some(t) = tape.translations.pop() {
transform.rotation = tape.rotations.pop().unwrap(); transform.translation = t;
}
if let Some(r) = tape.rotations.pop() {
transform.rotation = r;
}
}); });
} }
@ -193,10 +197,10 @@ fn detect_dead(
.any(|(_type_id, list)| list.contains(&(*bird))); .any(|(_type_id, list)| list.contains(&(*bird)));
if bird_visible { if bird_visible {
info!("Bird is visible, making alive"); debug!("Bird is visible, making alive");
next.set(PlayerState::Alive); next.set(PlayerState::Alive);
} else { } else {
info!("Bird is not visible, making dead"); debug!("Bird is not visible, making dead");
next.set(PlayerState::Dead); next.set(PlayerState::Dead);
} }
} }

Loading…
Cancel
Save