more bevy gettings started code
parent
ebc89c75d9
commit
e395417794
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 New Issue