32 lines
603 B
Rust
32 lines
603 B
Rust
|
use bevy::prelude::*;
|
||
|
|
||
|
pub struct BuildScenePlugin;
|
||
|
|
||
|
impl Plugin for BuildScenePlugin {
|
||
|
fn build(&self, app: &mut App) {
|
||
|
app
|
||
|
.add_startup_system(build_scene)
|
||
|
.add_system(print_positions);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
#[derive(Component)]
|
||
|
struct Person;
|
||
|
|
||
|
#[derive(Component)]
|
||
|
struct Position { x: f32, y: f32 }
|
||
|
|
||
|
|
||
|
fn build_scene(mut commands: Commands) {
|
||
|
commands.spawn()
|
||
|
.insert(Person)
|
||
|
.insert(Position{ x: 10.0, y: 10.0 });
|
||
|
}
|
||
|
|
||
|
fn print_positions(query : Query<&Position>) {
|
||
|
for position in query.iter() {
|
||
|
println!("position {:?} {:?}", position.x, position.y)
|
||
|
}
|
||
|
}
|