bevy/examples/headless.rs

37 lines
1,007 B
Rust
Raw Normal View History

2020-03-30 18:52:33 +00:00
use bevy::{
app::schedule_runner::{RunMode, ScheduleRunnerPlugin},
2020-03-30 18:52:33 +00:00
prelude::*,
};
use std::time::Duration;
// This example disables the default plugins by not registering them during setup.
// You can also completely remove rendering / windowing Plugin code from bevy
// by making your import look like this in your Cargo.toml
//
// [dependencies]
// bevy = { version = "0.1.0", default-features = false, features = ["headless"] }
2020-03-30 18:52:33 +00:00
fn main() {
// this app runs once
2020-03-30 18:52:33 +00:00
App::build()
.add_plugin(ScheduleRunnerPlugin {
2020-03-30 18:52:33 +00:00
run_mode: RunMode::Once,
})
.add_system(hello_world_system.system())
2020-03-30 18:52:33 +00:00
.run();
// this app loops forever at 60 fps
2020-03-30 18:52:33 +00:00
App::build()
.add_plugin(ScheduleRunnerPlugin {
2020-03-30 18:52:33 +00:00
run_mode: RunMode::Loop {
wait: Some(Duration::from_secs_f64(1.0 / 60.0)),
},
})
.add_system(hello_world_system.system())
2020-03-30 18:52:33 +00:00
.run();
}
fn hello_world_system() {
2020-04-30 17:42:22 +00:00
println!("hello world");
2020-03-30 18:52:33 +00:00
}