From 7ed037b2e8b20a6da5e45c7743ee674880d2284f Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Fri, 29 May 2026 22:55:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B5=D0=BA=D1=82=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20-=20WIP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bevy learning --- snake-game/examples/bevy_learning.rs | 49 ++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/snake-game/examples/bevy_learning.rs b/snake-game/examples/bevy_learning.rs index 40cca5a..ea3fbd3 100644 --- a/snake-game/examples/bevy_learning.rs +++ b/snake-game/examples/bevy_learning.rs @@ -11,7 +11,7 @@ fn main() { .build() .set(bevy::log::LogPlugin { 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(), ..Default::default() }) @@ -26,13 +26,48 @@ fn main() { .run(); } -fn setup(mut commands: Commands) { - commands.spawn(Camera2d); +fn setup(mut commands: Commands, _window: Query<&Window>) { + let _window = _window.single().unwrap(); + // trace!("window: {:?}", window.single()); - commands.spawn( - // - Sprite::from_color(Color::srgb(1., 1., 1.), Vec2::new(100., 50.)), - ); + let _red = commands + .spawn(( + 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) {