diff --git a/snake-game/examples/schedules_test.rs b/snake-game/examples/schedules_test.rs index 9e3cb9a..66e1b2b 100644 --- a/snake-game/examples/schedules_test.rs +++ b/snake-game/examples/schedules_test.rs @@ -1,15 +1,16 @@ -use bevy::{app::FixedMain, prelude::*}; +use bevy::prelude::*; fn main() { App::new() // .add_plugins(DefaultPlugins) .add_systems(StateTransition, state_transition) .add_systems(PreStartup, pre_startup) - .add_systems(Startup, startup) + .add_systems(Startup, (startup, setup)) .add_systems(PostStartup, post_startup) .add_systems(First, first) .add_systems(PreUpdate, pre_update) - .add_systems(FixedMain, fixed_main) + .add_systems(Update, (update, check_space_pressed)) + .add_systems(PostUpdate, post_update) .run(); } @@ -37,6 +38,21 @@ fn pre_update() { info!("PreUpdate"); } -fn fixed_main() { - info!("FixedMain"); +fn update() { + info!("Update"); } + +fn post_update() { + info!("PostUpdate"); +} + +fn check_space_pressed(input: Res>, mut commands: Commands) { + if input.just_pressed(KeyCode::Space) { + commands.trigger(TestEvent0); + } +} + +fn setup(mut commands: Commands) {} + +#[derive(Event)] +struct TestEvent0;