mirror of
https://github.com/OMGeeky/logisim.git
synced 2025-12-26 16:57:23 +01:00
finish getting started guide
This commit is contained in:
15
src/main.rs
15
src/main.rs
@@ -24,13 +24,15 @@ fn add_people(mut commands: Commands) {
|
||||
commands.spawn((Person, Name("Renzo Hume".to_string())));
|
||||
commands.spawn((Person, Name("Zayna Nieves".to_string())));
|
||||
}
|
||||
#[derive(Component)]
|
||||
#[derive(Resource)]
|
||||
struct GreetTimer(Timer);
|
||||
//endregion
|
||||
//region query
|
||||
fn greet_people(query: Query<&Name, With<Person>>) {
|
||||
for name in &query {
|
||||
println!("hello {}!", name.0);
|
||||
fn greet_people(time: Res<Time>, mut timer: ResMut<GreetTimer>, query: Query<&Name, With<Person>>) {
|
||||
if timer.0.tick(time.delta()).just_finished() {
|
||||
for name in &query {
|
||||
println!("hello {}!", name.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn update_people(mut query: Query<&mut Name, With<Person>>) {
|
||||
@@ -46,8 +48,9 @@ fn update_people(mut query: Query<&mut Name, With<Person>>) {
|
||||
pub struct HelloPlugin;
|
||||
impl Plugin for HelloPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, add_people)
|
||||
.add_systems(Update, (hello_world, (update_people, greet_people).chain()));
|
||||
app.insert_resource(GreetTimer(Timer::from_seconds(2.0, TimerMode::Repeating)))
|
||||
.add_systems(Startup, add_people)
|
||||
.add_systems(Update, ((update_people, greet_people).chain()));
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
|
||||
Reference in New Issue
Block a user