toying around
This commit is contained in:
parent
0e1061609c
commit
693f79de3c
2 changed files with 43 additions and 16 deletions
28
src/main.rs
28
src/main.rs
|
@ -1,22 +1,18 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
struct Position { x: f32, y:f32}
|
||||
|
||||
fn hello_world() {
|
||||
println!("Hello World!");
|
||||
}
|
||||
|
||||
|
||||
fn print_position_system(query : Query<&Transform>) {
|
||||
for transform in query.iter() {
|
||||
println!("position {:?}", transform.translation)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_system(hello_world)
|
||||
.insert_resource(ClearColor(Color::rgb(0.0,0.02,0.1)))
|
||||
.insert_resource(WindowDescriptor{
|
||||
title: "PixSpace".to_string(),
|
||||
width: 1280.0,
|
||||
height: 800.0,
|
||||
..Default::default()
|
||||
})
|
||||
.add_plugins(DefaultPlugins)
|
||||
// .add_plugin(BuildScenePlugin)
|
||||
// .add_system(hello_world)
|
||||
// .add_startup_system(add_scene)
|
||||
// .add_system(print_positions)
|
||||
.run();
|
||||
}
|
||||
|
|
31
src/scene.rs
Normal file
31
src/scene.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue