mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
31 lines
775 B
Rust
31 lines
775 B
Rust
use bevy::{
|
|
app::schedule_runner::{RunMode, ScheduleRunner},
|
|
prelude::*,
|
|
};
|
|
use std::time::Duration;
|
|
|
|
fn main() {
|
|
println!("This app runs once:");
|
|
App::build()
|
|
.add_plugin(ScheduleRunner {
|
|
run_mode: RunMode::Once,
|
|
})
|
|
.add_system(hello_world_system())
|
|
.run();
|
|
|
|
println!("This app loops forever at 60 fps:");
|
|
App::build()
|
|
.add_plugin(ScheduleRunner {
|
|
run_mode: RunMode::Loop {
|
|
wait: Some(Duration::from_secs_f64(1.0 / 60.0)),
|
|
},
|
|
})
|
|
.add_system(hello_world_system())
|
|
.run();
|
|
}
|
|
|
|
pub fn hello_world_system() -> Box<dyn Schedulable> {
|
|
SystemBuilder::new("hello_world").build(move |_, _, _, _| {
|
|
println!("hello world");
|
|
})
|
|
}
|