more bevy gettings started code
This commit is contained in:
parent
ebc89c75d9
commit
e395417794
1 changed files with 22 additions and 1 deletions
23
src/main.rs
23
src/main.rs
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue