From fe503f51de27f74e5afa5337da2a1906b45073a8 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Wed, 31 Jan 2024 16:47:17 +0000 Subject: [PATCH] Create a second chunk entity --- src/falling_sand/mod.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/falling_sand/mod.rs b/src/falling_sand/mod.rs index ee7d6a6..3eabbaf 100644 --- a/src/falling_sand/mod.rs +++ b/src/falling_sand/mod.rs @@ -49,18 +49,23 @@ fn setup(mut commands: Commands, mut images: ResMut>) { TextureFormat::Rgba8UnormSrgb, ); - let image_handle = images.add(image); - - commands.spawn(Chunk::new(256, 256)).insert(SpriteBundle { + let sprite_bundle1 = SpriteBundle { sprite: Sprite { flip_y: true, ..default() }, - texture: image_handle, + texture: images.add(image.clone()), transform: Transform::from_translation(Vec3::new(256., 0., 0.)) .with_scale(Vec3::new(2., 2., 0.)), ..default() - }); + }; + let mut sprite_bundle2 = sprite_bundle1.clone(); + sprite_bundle2.texture = images.add(image.clone()); + sprite_bundle2.transform = + Transform::from_translation(Vec3::new(-256., 0., 0.)).with_scale(Vec3::new(2., 2., 0.)); + + commands.spawn(Chunk::new(256, 256)).insert(sprite_bundle1); + commands.spawn(Chunk::new(256, 256)).insert(sprite_bundle2); } #[derive(Component)]