more bevy gettings started code

This commit is contained in:
Zynh Ludwig 2024-07-29 23:01:55 -07:00
parent ebc89c75d9
commit e395417794

View file

@ -1,9 +1,30 @@
use bevy::prelude::*;
fn main() {
App::new().add_systems(Update, hello_world).run();
App::new()
.add_systems(Startup, add_people)
.add_systems(Update, (hello_world, greet_people).chain())
.run();
}
fn hello_world() {
println!("uwu!");
}
#[derive(Component)]
struct Person;
#[derive(Component)]
struct Name(String);
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);
}
}