From e3954177942a7fb82d20e7b0e18220a922083d36 Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Mon, 29 Jul 2024 23:01:55 -0700 Subject: [PATCH] more bevy gettings started code --- src/main.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index daa0064..2d16eca 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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>) { + for name in &query { + println!("hello {}!", name.0); + } +}