Skip to content

Commit

Permalink
Fix a but that game time is slightly slower than the realtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ramirisu committed Sep 18, 2024
1 parent 5894223 commit 0684549
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/game/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,28 @@ pub fn setup(app: &mut App) {
Update,
(
(
increase_game_stopwatch_system,
state_game_running::tick_system,
state_game_running::handle_input_system,
state_game_running::curr_piece_fall_system,
update_statistics_system,
)
.chain()
.run_if(in_state(PlayerState::GameRunning)),
(state_game_line_clear::tick_system, update_statistics_system)
(
increase_game_stopwatch_system,
state_game_line_clear::tick_system,
update_statistics_system,
)
.chain()
.run_if(in_state(PlayerState::GameLineClear)),
state_game_update_assets::update_square_image_assets
.run_if(in_state(PlayerState::GameUpdateSquareImageAssets)),
state_game_entry_delay::tick_system.run_if(in_state(PlayerState::GameEntryDelay)),
(
increase_game_stopwatch_system,
state_game_entry_delay::tick_system,
)
.run_if(in_state(PlayerState::GameEntryDelay)),
state_game_pause::handle_input_system.run_if(in_state(PlayerState::GamePause)),
state_game_over::handle_input_system.run_if(in_state(PlayerState::GameOver)),
)
Expand Down Expand Up @@ -473,6 +482,10 @@ fn setup_screen(
});
}

fn increase_game_stopwatch_system(time: Res<Time>, mut player_data: ResMut<PlayerData>) {
player_data.game_stopwatch.tick(time.delta());
}

fn update_statistics_system(
mut query: ParamSet<(
Query<&mut Text, With<LinesEntityMarker>>,
Expand Down Expand Up @@ -540,7 +553,6 @@ mod state_game_running {
use super::*;

pub(super) fn tick_system(time: Res<Time>, mut player_data: ResMut<PlayerData>) {
player_data.game_stopwatch.tick(time.delta());
player_data.game_timer.tick(time.delta());
player_data.press_down_timer.tick(time.delta());
}
Expand Down

0 comments on commit 0684549

Please sign in to comment.