From 4b672ebdb61669dbd2c14fe1220dec0fb1f90f0d Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Sun, 8 Sep 2024 18:44:03 +0200 Subject: trying out bevy 13 --- src/cell.rs | 8 +++--- src/main.rs | 95 ++++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 66 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/cell.rs b/src/cell.rs index 6571cd5..d865c97 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -102,13 +102,13 @@ impl Cell { } } - pub fn set_occupant(&mut self, occupant: Occupant, sprite: &mut TextureAtlasSprite) { + pub fn set_occupant(&mut self, occupant: Occupant, sprite: &mut TextureAtlas) { self.occupant = occupant; sprite.index = self.occupant.to_index(); } } -pub fn insert(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { +pub fn insert(mut q: Query<(&mut Cell, &mut TextureAtlas)>) { for (mut cell, mut sprite) in q.iter_mut() { if cell.occupant == Occupant::None && cell.y == constants::GRID_SIZE - 1 { cell.set_occupant(rand::random(), &mut sprite); @@ -129,7 +129,7 @@ pub fn start_explosion( } } -pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { +pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlas)>) { let mut cells = [[Cell::default(); constants::GRID_SIZE]; constants::GRID_SIZE]; for (cell, _) in q.iter_mut() { cells[cell.x][cell.y] = *cell; @@ -185,7 +185,7 @@ pub fn check(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { } } -pub fn falling(mut q: Query<(&mut Cell, &mut TextureAtlasSprite)>) { +pub fn falling(mut q: Query<(&mut Cell, &mut TextureAtlas)>) { let mut have_gems = Vec::new(); for (cell, _sprite) in q.iter_mut() { if cell.occupant != Occupant::None { diff --git a/src/main.rs b/src/main.rs index 136bb87..7eee0ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,9 +9,13 @@ use std::time::Duration; fn star_spawning( mut commands: Commands, time: Res