From cf1491c2b60540c785233a9be18438c43eb0a6e6 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Sun, 27 Jul 2025 15:12:37 -0700 Subject: [PATCH] rewind button --- src/bin/flappy/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/bin/flappy/main.rs b/src/bin/flappy/main.rs index b8393d9..e94e5dc 100644 --- a/src/bin/flappy/main.rs +++ b/src/bin/flappy/main.rs @@ -206,6 +206,27 @@ fn init_ui( Text::new("Go!"), ], )).observe(start_game); + + fn start_rewind(trigger: Trigger>, mut next: ResMut>) { + next.set(PlayerState::Rewind); + } + + fn end_rewind(trigger: Trigger>, mut next: ResMut>) { + next.set(PlayerState::Alive); + } + + commands.spawn(( + Node { + align_self: AlignSelf::End, + justify_self: JustifySelf::Center, + flex_direction: FlexDirection::Column, + ..default() + }, + Button, + children![ + Text::new("Rewind!"), + ], + )).observe(start_rewind).observe(end_rewind); } /// Pause the game when the player presses "Escape"