2020-11-02 19:38:37 -07:00
|
|
|
use bevy::{
|
|
|
|
app::{ScheduleRunnerPlugin, ScheduleRunnerSettings},
|
2020-11-12 17:23:57 -08:00
|
|
|
log::LogPlugin,
|
2020-11-02 19:38:37 -07:00
|
|
|
prelude::*,
|
2020-11-22 01:38:24 +01:00
|
|
|
utils::Duration,
|
2020-11-02 19:38:37 -07:00
|
|
|
};
|
2020-09-16 03:05:31 +02:00
|
|
|
|
|
|
|
fn main() {
|
2021-07-27 20:21:06 +00:00
|
|
|
App::new()
|
2021-01-30 15:55:13 -05:00
|
|
|
.insert_resource(ScheduleRunnerSettings::run_loop(Duration::from_secs_f64(
|
2020-09-16 03:05:31 +02:00
|
|
|
1.0 / 60.0,
|
|
|
|
)))
|
2020-11-02 19:38:37 -07:00
|
|
|
.add_plugin(ScheduleRunnerPlugin::default())
|
2020-11-12 17:23:57 -08:00
|
|
|
.add_plugin(LogPlugin::default())
|
2021-07-27 23:42:36 +00:00
|
|
|
.add_startup_system(hello_world_system)
|
|
|
|
.add_system(counter)
|
2020-09-16 03:05:31 +02:00
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn hello_world_system() {
|
2020-11-12 17:23:57 -08:00
|
|
|
info!("hello wasm");
|
2020-09-16 03:05:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn counter(mut state: Local<CounterState>) {
|
|
|
|
if state.count % 60 == 0 {
|
2020-11-12 17:23:57 -08:00
|
|
|
info!("counter system: {}", state.count);
|
2020-09-16 03:05:31 +02:00
|
|
|
}
|
|
|
|
state.count += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Default)]
|
|
|
|
struct CounterState {
|
|
|
|
count: u32,
|
|
|
|
}
|