mirror of
https://github.com/OMGeeky/logisim.git
synced 2025-12-26 16:57:23 +01:00
follow getting started guide
This commit is contained in:
30
src/main.rs
30
src/main.rs
@@ -2,8 +2,8 @@ use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_systems(Startup, add_people)
|
||||
.add_systems(Update, hello_world)
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugins(HelloPlugin)
|
||||
.run();
|
||||
}
|
||||
//region first app
|
||||
@@ -24,5 +24,31 @@ fn add_people(mut commands: Commands) {
|
||||
commands.spawn((Person, Name("Renzo Hume".to_string())));
|
||||
commands.spawn((Person, Name("Zayna Nieves".to_string())));
|
||||
}
|
||||
#[derive(Component)]
|
||||
struct GreetTimer(Timer);
|
||||
//endregion
|
||||
//region query
|
||||
fn greet_people(query: Query<&Name, With<Person>>) {
|
||||
for name in &query {
|
||||
println!("hello {}!", name.0);
|
||||
}
|
||||
}
|
||||
fn update_people(mut query: Query<&mut Name, With<Person>>) {
|
||||
for mut name in &mut query {
|
||||
if name.0 == "Elaina Proctor" {
|
||||
name.0 = "Elaina Hume".to_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
//region Plugin
|
||||
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()));
|
||||
}
|
||||
}
|
||||
//endregion
|
||||
//endregion
|
||||
|
||||
Reference in New Issue
Block a user