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