Toggling states simpler for testing

This commit is contained in:
Daniel Flanagan 2024-07-29 16:41:16 -05:00
parent 4a6d9ee223
commit 9242f39bb0
2 changed files with 13 additions and 6 deletions

View file

@ -64,13 +64,19 @@ pub fn exit(mut commands: Commands, q: Query<Entity, With<MainMenu>>) {
}
pub fn update(
keyboard_input: Res<ButtonInput<KeyCode>>,
keyboard: Res<ButtonInput<KeyCode>>,
mut next_state: ResMut<NextState<crate::View>>,
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>,
) {
if keyboard_input.just_pressed(KeyCode::Escape) {
app_exit_events.send(bevy::app::AppExit);
} else if keyboard_input.pressed(KeyCode::Enter) {
next_state.set(crate::View::InGame)
for key in keyboard.get_just_pressed() {
match key {
KeyCode::Escape => {
app_exit_events.send(bevy::app::AppExit);
}
KeyCode::Enter => {
next_state.set(crate::View::InGame);
}
_ => {}
}
}
}

View file

@ -49,7 +49,7 @@ pub fn startup(
text: Text::from_section(
"You",
TextStyle {
font_size: 32.0,
font_size: 100.0,
font: assets.fonts.iosevkalytemin.clone(),
color: Color::WHITE,
..Default::default()
@ -148,6 +148,7 @@ pub fn controls(
for key in input.get_just_pressed() {
match key {
KeyCode::Escape => next_state.set(crate::View::MainMenu),
KeyCode::Enter => next_state.set(crate::View::MainMenu),
KeyCode::Space => {
let child = commands
.spawn(AudioSourceBundle {