2024-03-16 14:00:31 +00:00
|
|
|
use bevy::prelude::*;
|
|
|
|
|
2024-03-16 13:27:22 +00:00
|
|
|
fn main() {
|
2024-03-16 14:00:31 +00:00
|
|
|
App::new()
|
|
|
|
.add_systems(Startup, add_people)
|
|
|
|
.add_systems(Update, (hello_world, greet_people))
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
struct Name(String);
|
|
|
|
|
|
|
|
#[derive(Component)]
|
|
|
|
struct Person;
|
|
|
|
|
|
|
|
fn add_people(mut commands: Commands) {
|
|
|
|
commands.spawn((Person, Name("Elaina Proctor".to_string())));
|
|
|
|
commands.spawn((Person, Name("Renzo Hume".to_string())));
|
|
|
|
commands.spawn((Person, Name("Zayna Nieves".to_string())));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn greet_people(query: Query<&Name, With<Person>>) {
|
|
|
|
for name in &query {
|
|
|
|
println!("hello {}!", name.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn hello_world() {
|
|
|
|
println!("hello world!");
|
2024-03-16 13:27:22 +00:00
|
|
|
}
|