Skip to content

Commit

Permalink
revised the basic structure for timer button
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv-0831 committed Oct 14, 2023
1 parent f48ed14 commit 0e14689
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,18 @@ public void createTimerButton() {
* This method updates the text for timer button.
*/
public void updateTimerButton() {
int totalSecs = (int) (timer - (ServiceLocator.getTimeSource().getTime() / 1000));
int totalSecs = (int) ((ServiceLocator.getWaveService().getNextWaveTime()
- ServiceLocator.getTimeSource().getTime()) / 1000);
int seconds = totalSecs % 60;
int minutes = (totalSecs % 3600) / 60;
String finalTime = String.format("%02d:%02d", minutes, seconds);
timerButton.setText("Next wave in:" + finalTime);
if (ServiceLocator.getTimeSource().getTime() < ServiceLocator.getWaveService().getNextWaveTime()) {
timerButton.setText("Next wave in: " + finalTime);
} else {
buttonTable.removeActor(timerButton);
stage.act();
stage.draw();
}
}

@Override
Expand Down

0 comments on commit 0e14689

Please sign in to comment.