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-10-02 19:24:30 +00:00
|
|
|
use std::time::Duration;
|
2020-09-16 01:05:31 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
App::build()
|
2020-11-03 02:38:37 +00:00
|
|
|
.add_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-09-16 01:05:31 +00:00
|
|
|
.add_startup_system(hello_world_system.system())
|
|
|
|
.add_system(counter.system())
|
|
|
|
.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,
|
|
|
|
}
|