From 36724b960281e591e6e3364974e8ca7400746468 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 16 Mar 2024 15:00:31 +0100 Subject: [PATCH] working through the bevy tutorial --- src/main.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e7a11a9..2850615 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,30 @@ +use bevy::prelude::*; + fn main() { - println!("Hello, world!"); + 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>) { + for name in &query { + println!("hello {}!", name.0); + } +} + +fn hello_world() { + println!("hello world!"); }