mirror of
https://github.com/scratchfoundation/scratch-tech-explorations.git
synced 2025-08-28 21:38:45 -04:00
feat: use some Bevy systems to print some messages
This commit is contained in:
parent
4274ec5373
commit
dd577c6018
1 changed files with 28 additions and 1 deletions
29
src/main.rs
29
src/main.rs
|
@ -1,3 +1,30 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
App::new()
|
||||
.add_startup_system(add_default_sprites)
|
||||
.add_system(hello_world)
|
||||
.add_system(print_sprite_names)
|
||||
.run();
|
||||
}
|
||||
|
||||
fn hello_world() {
|
||||
println!("hello, world!");
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
struct Sprite;
|
||||
|
||||
#[derive(Component)]
|
||||
struct Name(String);
|
||||
|
||||
fn add_default_sprites(mut commands: Commands) {
|
||||
commands.spawn().insert(Sprite).insert(Name("Sprite 1".to_string()));
|
||||
commands.spawn().insert(Sprite).insert(Name("Sprite 2".to_string()));
|
||||
}
|
||||
|
||||
fn print_sprite_names(query: Query<&Name, With<Sprite>>) {
|
||||
for name in query.iter() {
|
||||
println!("found a sprite named {}", name.0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue