From 94a432033f4e98e87a0793eccac840ee24d04512 Mon Sep 17 00:00:00 2001 From: Vova_rs Date: Fri, 5 Jun 2026 13:37:54 +0300 Subject: [PATCH] ECS basis --- src/main.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1d183d1..81454ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,5 +5,32 @@ fn main() { App::new() .add_plugins(DefaultPlugins) + .add_systems(Startup, setup) + .add_systems(Update, moveng) .run(); } + +#[derive(Component)] +struct Move; + +fn setup(mut commands: Commands, assets: Res){ + commands.spawn((Camera2d, Move)); + + commands.spawn(( + Sprite::from_image(assets.load("002.png")), + Transform::from_scale(Vec3::splat(0.25)), + Move, + )); + + commands.spawn(( + Sprite::from_image(assets.load("000.png")), + Transform::from_xyz(0.0, 0.0, -1.) + )); +} + + +fn moveng(mut m_sprite: Query<(&mut Transform, &Move)>){ + for (mut tr, _) in m_sprite { + tr.translation.x += 0.5; + } +}