ECS basis

This commit is contained in:
vova-rs committed 2026-06-05 13:37:54 +03:00
1 parent 55c82a6d0e
commit 94a432033f
1 file changed
+27
+27
View File
@@ -5,5 +5,32 @@ fn main() {
App::new() App::new()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, moveng)
.run(); .run();
} }
#[derive(Component)]
struct Move;
fn setup(mut commands: Commands, assets: Res<AssetServer>){
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;
}
}