Skip to content

Commit

Permalink
reset score and spawn timer when resetting game - fixes #114
Browse files Browse the repository at this point in the history
  • Loading branch information
thombruce committed Nov 19, 2023
1 parent 6148d5f commit 91c1106
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- PlayTime resource records unpaused play time

### Fixed

- Reset score on game reset
- Reset SpawnTimer on game reset

## [0.0.26] - 2023-11-18

### Added
Expand Down
10 changes: 9 additions & 1 deletion src/systems/states/transitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use bevy::{
};
use bevy_picking_core::pointer::PointerId;

use crate::core::resources::{assets::AudioAssets, game_time::GameTime};
use crate::{
core::resources::{assets::AudioAssets, game_time::GameTime, score::Score},
ships::enemy::SpawnTimer,
};

use super::{ForState, GameState};

Expand Down Expand Up @@ -45,6 +48,8 @@ pub(crate) fn game_reset(
mut next_state: ResMut<NextState<GameState>>,
mut window: Query<&mut Window>,
mut game_time: ResMut<GameTime>,
mut score: ResMut<Score>,
mut spawn_timer: ResMut<SpawnTimer>,
) {
for entity in entities.iter() {
commands.entity(entity).despawn_recursive();
Expand All @@ -55,7 +60,10 @@ pub(crate) fn game_reset(
..default()
};

// TODO: Create a shared resource for game resources
game_time.0.reset();
score.0 = 0;
spawn_timer.0.reset();

next_state.set(GameState::Loading);
}
Expand Down

0 comments on commit 91c1106

Please sign in to comment.