summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs
index 8a59000..c69d791 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -100,7 +100,10 @@ pub fn setup(
commands
.spawn_bundle(SpriteSheetBundle {
texture_atlas: atlas_handle.clone(),
- sprite: TextureAtlasSprite::new(constants::TILESHEET_NONE1),
+ visible: Visible {
+ is_visible: false,
+ is_transparent: true,
+ },
transform: Transform {
translation: Vec3::new(
((i as f32) * constants::TILE_SIZE * constants::TILE_SCALE) - 330.0,
@@ -125,35 +128,35 @@ fn animation(
Option<&mut Cell>,
&mut Timer,
&mut TextureAtlasSprite,
+ &mut Visible,
)>,
) {
- for (entity, cell, mut timer, mut sprite) in q.iter_mut() {
+ for (entity, cell, mut timer, mut sprite, mut visible) in q.iter_mut() {
timer.tick(time.delta());
if timer.finished() {
let index = match sprite.index {
- constants::TILESHEET_EXPLOSION1 => constants::TILESHEET_EXPLOSION2,
- constants::TILESHEET_EXPLOSION2 => constants::TILESHEET_EXPLOSION3,
- constants::TILESHEET_EXPLOSION3 => constants::TILESHEET_EXPLOSION4,
+ constants::TILESHEET_EXPLOSION1 => Some(constants::TILESHEET_EXPLOSION2),
+ constants::TILESHEET_EXPLOSION2 => Some(constants::TILESHEET_EXPLOSION3),
+ constants::TILESHEET_EXPLOSION3 => Some(constants::TILESHEET_EXPLOSION4),
+ constants::TILESHEET_EXPLOSION4 => Some(constants::TILESHEET_EXPLOSION5),
- constants::TILESHEET_VISOR1 => constants::TILESHEET_VISOR2,
- constants::TILESHEET_VISOR2 => constants::TILESHEET_VISOR3,
- constants::TILESHEET_VISOR3 => constants::TILESHEET_VISOR4,
+ constants::TILESHEET_VISOR1 => Some(constants::TILESHEET_VISOR2),
+ constants::TILESHEET_VISOR2 => Some(constants::TILESHEET_VISOR3),
+ constants::TILESHEET_VISOR3 => Some(constants::TILESHEET_VISOR4),
- constants::TILESHEET_STAR1 => constants::TILESHEET_STAR2,
- constants::TILESHEET_STAR2 => constants::TILESHEET_STAR3,
+ constants::TILESHEET_STAR1 => Some(constants::TILESHEET_STAR2),
+ constants::TILESHEET_STAR2 => Some(constants::TILESHEET_STAR3),
- constants::TILESHEET_NONE1 => constants::TILESHEET_NONE2,
- _ => constants::TILESHEET_NONE1,
+ _ => None,
};
- sprite.index = index;
- if index == constants::TILESHEET_NONE2 {
- if let Some(mut cell) = cell {
- cell.occupant = Occupant::None;
- sprite.index = cell.occupant.to_index();
- commands.entity(entity).remove::<Timer>();
- } else {
- commands.entity(entity).despawn();
- }
+
+ if let Some(index) = index {
+ sprite.index = index;
+ } else if let Some(mut cell) = cell {
+ cell.set_occupant(Occupant::None, &mut sprite, &mut visible);
+ commands.entity(entity).remove::<Timer>();
+ } else {
+ commands.entity(entity).despawn();
}
}
}