more bevy gettings started code

main
Zynh Ludwig 2024-07-29 23:01:55 -07:00
parent ebc89c75d9
commit e395417794
1 changed files with 22 additions and 1 deletions

View File

@ -1,9 +1,30 @@
use bevy::prelude::*; use bevy::prelude::*;
fn main() { 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() { fn hello_world() {
println!("uwu!"); 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);
}
}