Проектная работа - WIP

bevy learning
This commit is contained in:
+42 -7
View File
@@ -11,7 +11,7 @@ fn main() {
.build() .build()
.set(bevy::log::LogPlugin { .set(bevy::log::LogPlugin {
level: Level::INFO, level: Level::INFO,
filter: "bevy_app=trace".to_string(), filter: "wgpu_hal=warn,bevy_learning=trace".to_string(),
fmt_layer: |_| snake_game::define_log_layer(), fmt_layer: |_| snake_game::define_log_layer(),
..Default::default() ..Default::default()
}) })
@@ -26,13 +26,48 @@ fn main() {
.run(); .run();
} }
fn setup(mut commands: Commands) { fn setup(mut commands: Commands, _window: Query<&Window>) {
commands.spawn(Camera2d); let _window = _window.single().unwrap();
// trace!("window: {:?}", window.single());
commands.spawn( let _red = commands
// .spawn((
Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 50.)), Sprite::from_color(Color::srgb(1., 0., 0.), Vec2::new(30., 30.)),
); Transform {
translation: vec3(-20., 30., 1.),
..Default::default()
},
// ChildOf(_root),
))
.id();
let _blue = commands
.spawn((
Sprite::from_color(Color::srgb(0., 0., 1.), Vec2::new(20., 20.)),
Transform {
translation: vec3(20., 30., 1.),
..Default::default()
},
// ChildOf(_root),
))
.id();
let x = -_window.resolution.width() / 2. + 52.;
let y = -_window.resolution.height() / 2. + 52.;
let _root = commands
.spawn((
Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 100.)),
Transform {
translation: vec3(x, y, 1.),
// scale: Vec3::new(1., 1., 1.),
..Default::default()
},
))
.id();
commands.entity(_red).insert(ChildOf(_root));
commands.entity(_blue).insert(ChildOf(_root));
commands.spawn(Camera2d);
} }
fn print_all_entities(mut commands: Commands, query: Query<Entity>) { fn print_all_entities(mut commands: Commands, query: Query<Entity>) {