Create a second chunk entity

This commit is contained in:
Jarrod Doyle 2024-01-31 16:47:17 +00:00
parent b1fd987955
commit fe503f51de
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 10 additions and 5 deletions

View File

@ -49,18 +49,23 @@ fn setup(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
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)]