summaryrefslogtreecommitdiff
path: root/src/cell.rs
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-03-21 19:36:32 +0100
committerTom Barrett <tom@tombarrett.xyz>2021-03-21 19:36:32 +0100
commit9a57ab99eb0162cbc55064639db69a1d9ff26d76 (patch)
tree720adfa791cb21bf2499ff332ca22a371247af9a /src/cell.rs
parent585d82473ccf566965ded0e50eea1669c3e1cdf3 (diff)
s/cell_query/q
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs27
1 files changed, 12 insertions, 15 deletions
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<Timer>>,
-) {
- for (entity, cell) in cell_query.iter_mut() {
+pub fn start_explosion(commands: &mut Commands, mut q: Query<(Entity, &Cell), Without<Timer>>) {
+ 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();