PixSpace/src/scene.rs

45 lines
957 B
Rust
Raw Normal View History

2022-07-15 23:42:22 +02:00
use bevy::prelude::*;
pub struct BuildScenePlugin;
impl Plugin for BuildScenePlugin {
fn build(&self, app: &mut App) {
2022-11-16 23:07:49 +01:00
app.add_startup_system(build_scene) // actual scene
.add_system(print_positions); // debugging
2022-07-15 23:42:22 +02:00
}
}
#[derive(Component)]
struct Person;
#[derive(Component)]
2022-11-16 23:07:49 +01:00
pub struct Position { x: f32, y: f32 }
2022-07-15 23:42:22 +02:00
2022-11-16 23:07:49 +01:00
pub fn build_scene(mut commands: Commands) {
2022-11-16 23:32:35 +01:00
commands.spawn((
Person,
Position { x: 10.0, y: 10.0 }
)
);
// commands.spawn()
// .insert(Person)
// .insert(Position { x: 10.0, y: 10.0 } );
2022-08-07 22:26:12 +02:00
// camera
// commands.spawn_bundle(OffAxisProjection {
// transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
// ..default()
// });
2022-07-15 23:42:22 +02:00
}
2022-11-16 23:07:49 +01:00
pub fn print_positions(query : Query<&Position>) {
for _position in query.iter() {
2022-08-07 22:26:12 +02:00
2022-11-16 23:07:49 +01:00
_ = 33;
2022-08-07 22:26:12 +02:00
// println!("position {:?} {:?}", position.x, position.y)
2022-07-15 23:42:22 +02:00
}
}