From 9a57ab99eb0162cbc55064639db69a1d9ff26d76 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Sun, 21 Mar 2021 19:36:32 +0100 Subject: s/cell_query/q --- src/cell.rs | 27 ++++++++++++--------------- src/main.rs | 20 ++++++++++---------- 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/cell.rs b/src/cell.rs index fc5d77d..48bc387 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -67,8 +67,8 @@ impl Cell { } } -pub fn insert(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { - for (mut cell, mut sprite) in cell_query.iter_mut() { +pub fn insert(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { + for (mut cell, mut sprite) in q.iter_mut() { if cell.occupant == Occupant::None && cell.y == constants::GRID_SIZE - 1 { cell.occupant = rand::random(); sprite.index = cell.occupant.to_index(); @@ -76,20 +76,17 @@ pub fn insert(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { } } -pub fn start_explosion( - commands: &mut Commands, - mut cell_query: Query<(Entity, &Cell), Without>, -) { - for (entity, cell) in cell_query.iter_mut() { +pub fn start_explosion(commands: &mut Commands, mut q: Query<(Entity, &Cell), Without>) { + for (entity, cell) in q.iter_mut() { if cell.occupant == Occupant::Explosion { commands.insert(entity, (Timer::from_seconds(0.1, true),)); } } } -pub fn check(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { +pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { let mut cells = [[Cell::default(); constants::GRID_SIZE]; constants::GRID_SIZE]; - for (cell, _) in cell_query.iter_mut() { + for (cell, _) in q.iter_mut() { cells[cell.x][cell.y] = *cell; } @@ -115,7 +112,7 @@ pub fn check(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { for c in connected.iter() { if c.len() > 4 { for (i, j) in c.iter() { - for (mut cell, mut sprite) in cell_query.iter_mut() { + for (mut cell, mut sprite) in q.iter_mut() { if &cell.x == i && &cell.y == j && cell.occupant != Occupant::Explosion { cell.occupant = Occupant::Explosion; sprite.index = cell.occupant.to_index(); @@ -146,7 +143,7 @@ pub fn check(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { for c in connected.iter() { if c.len() > 4 { for (i, j) in c.iter() { - for (mut cell, mut sprite) in cell_query.iter_mut() { + for (mut cell, mut sprite) in q.iter_mut() { if &cell.x == i && &cell.y == j && cell.occupant != Occupant::Explosion { cell.occupant = Occupant::Explosion; sprite.index = cell.occupant.to_index(); @@ -157,16 +154,16 @@ pub fn check(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { } } -pub fn falling(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { +pub fn falling(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { let mut have_gems = Vec::new(); - for (cell, _sprite) in cell_query.iter_mut() { + for (cell, _sprite) in q.iter_mut() { if cell.occupant != Occupant::None { have_gems.push(*cell); } } let mut moved_gems = Vec::new(); - for (mut cell, mut sprite) in cell_query.iter_mut() { + for (mut cell, mut sprite) in q.iter_mut() { if cell.occupant == Occupant::None { if let Some(c) = have_gems .iter() @@ -179,7 +176,7 @@ pub fn falling(mut cell_query: Query<(&mut Cell, &mut TextureAtlasSprite)>) { } } - for (mut cell, mut sprite) in cell_query.iter_mut() { + for (mut cell, mut sprite) in q.iter_mut() { if moved_gems.iter().any(|c| (c.x, c.y) == (cell.x, cell.y)) { cell.occupant = Occupant::None; sprite.index = cell.occupant.to_index(); diff --git a/src/main.rs b/src/main.rs index 624aa5b..79c0f2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -118,14 +118,14 @@ pub fn setup( fn animation_system( commands: &mut Commands, time: Res