You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
Rust
52 lines
1.3 KiB
Rust
use games::*;
|
|
|
|
fn main() {
|
|
App::new()
|
|
.init_resource::<Thing>()
|
|
.add_plugins(BaseGamePlugin::default())
|
|
.add_systems(Startup, init_ui)
|
|
.add_systems(
|
|
Update,
|
|
(
|
|
sync_resource_to_ui::<Thing>.run_if(resource_changed::<Thing>),
|
|
update_foo.run_if(on_event::<MouseMotion>),
|
|
),
|
|
)
|
|
.run();
|
|
}
|
|
|
|
#[derive(Resource, Debug, Default)]
|
|
struct Thing(u8);
|
|
|
|
impl Display for Thing {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|
|
|
|
fn init_ui(mut commands: Commands) {
|
|
commands.spawn((
|
|
Node {
|
|
align_self: AlignSelf::Start,
|
|
justify_self: JustifySelf::Center,
|
|
..default()
|
|
},
|
|
Text("Displays a sync'd resource tracking the number of mouse events (mod 256)".into()),
|
|
));
|
|
commands.spawn((
|
|
Node {
|
|
align_self: AlignSelf::Center,
|
|
justify_self: JustifySelf::Center,
|
|
..default()
|
|
},
|
|
Text("Placeholder".into()),
|
|
SyncResource::<Thing>::default(),
|
|
));
|
|
}
|
|
|
|
fn update_foo(mut events: EventReader<MouseMotion>, mut thing: ResMut<Thing>) {
|
|
events.read().for_each(|_| {
|
|
thing.0 = thing.0.overflowing_add(1).0;
|
|
});
|
|
}
|