Files
rust-otus/snake-game/examples/schedules_test.rs
T

59 lines
1.1 KiB
Rust

use bevy::prelude::*;
fn main() {
App::new() //
.add_plugins(DefaultPlugins)
.add_systems(StateTransition, state_transition)
.add_systems(PreStartup, pre_startup)
.add_systems(Startup, (startup, setup))
.add_systems(PostStartup, post_startup)
.add_systems(First, first)
.add_systems(PreUpdate, pre_update)
.add_systems(Update, (update, check_space_pressed))
.add_systems(PostUpdate, post_update)
.run();
}
fn state_transition() {
info!("StateTransition");
}
fn pre_startup() {
info!("PreStartup");
}
fn startup() {
info!("Startup");
}
fn post_startup() {
info!("PostStartup");
}
fn first() {
info!("First");
}
fn pre_update() {
info!("PreUpdate");
}
fn update() {
info!("Update");
}
fn post_update() {
info!("PostUpdate");
}
fn check_space_pressed(input: Res<ButtonInput<KeyCode>>, mut commands: Commands) {
if input.just_pressed(KeyCode::Space) {
commands.trigger(TestEvent0);
}
}
fn setup(mut commands: Commands) {}
#[derive(Event)]
struct TestEvent0;