I believe I fixed the rewind bug

main
Elijah Voigt 2 months ago
parent 8c440317e7
commit fd716e3989

BIN
assets/flappy/background-gradient.png (Stored with Git LFS)

Binary file not shown.

BIN
assets/flappy/background-gradient.xcf (Stored with Git LFS)

Binary file not shown.

@ -90,7 +90,7 @@ fn main() {
(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>),
move_batches.run_if(on_event::<CollisionStarted>.or(on_event::<CollisionEnded>)),
manage_score.run_if(on_event::<CollisionStarted>.or(on_event::<CollisionEnded>)),
shimmer_button::<RewindButton>.run_if(in_state(PlayerState::Stasis)),
shimmer_button::<FlapButton>.run_if(in_state(PlayerState::Pause)),
@ -240,7 +240,7 @@ fn update_batch_position(
mut root_changes: Query<(&mut Transform, &Batch), (Changed<Batch>, Without<ChildOf>)>,
) {
root_changes.iter_mut().for_each(|(mut t, Batch(idx))| {
info!("Updating batch {:?}", idx);
debug!("Updating batch {:?}", idx);
t.translation.x = 500.0 * (*idx) as f32;
});
}
@ -939,12 +939,16 @@ fn manage_score(
/// This includes root batch entities as well as pipes and hitboxes
fn move_batches(
mut start: EventReader<CollisionStarted>,
mut end: EventReader<CollisionEnded>,
hitboxes: Query<Entity, With<Hitbox>>,
batches: Query<(Entity, &Batch)>,
state: Res<State<PlayerState>>,
mut commands: Commands,
) {
start.read().for_each(|CollisionStarted(a, b)| {
let s = start.read().map(|CollisionStarted(a, b)| (a, b));
let e = end.read().map(|CollisionEnded(a, b)| (a, b));
let c = s.chain(e);
c.for_each(|(a, b)| {
debug!("[batches] Collision {a} -> {b}");
let target = {
@ -959,7 +963,7 @@ fn move_batches(
let (_, Batch(curr)) = batches.get(target).unwrap();
info!("[batches] Current: {curr}");
debug!("[batches] Current: {curr}");
let (old_batch, new_batch) = match state.get() {
PlayerState::Alive => (curr.saturating_sub(2), curr.saturating_add(2)),
PlayerState::Rewind => (curr.saturating_add(2), curr.saturating_sub(2)),
@ -972,7 +976,7 @@ fn move_batches(
// Filter to just entities with this batch ID
.filter_map(|(e, Batch(id))| (*id == old_batch).then_some(e))
.for_each(|old| {
info!("Moving batch {old_batch}({old}) -> {new_batch}");
debug!("Moving batch {old_batch}({old}) -> {new_batch}");
commands.entity(old).insert(Batch(new_batch));
})
}

Loading…
Cancel
Save