Skip to content
Snippets Groups Projects
Commit 37ab3718 authored by marcus's avatar marcus
Browse files

Goes to waitinglobbyView if timer is finished. Time is displayed as int instead of float.

parent 06f18d93
No related branches found
No related tags found
2 merge requests!22Resolve "Create game model",!20Goes to waitinglobbyView if timer is finished. Time is displayed as int instead of float.
...@@ -197,9 +197,15 @@ public class GamePlayController { ...@@ -197,9 +197,15 @@ public class GamePlayController {
public void update(float dt) { public void update(float dt) {
gamePlayView.update(dt); gamePlayView.update(dt);
handleInput(); handleInput();
//Check if gameTimer is up. If so allert database, award player 0 points and go to waitingLobby.
if (!gamePlayView.isTimerRunning()){
_FBIC.updateFinishedFlag(nickname, pin);
state.getStateManager().setState(new WaitingLobbyState(state.getStateManager(), _FBIC, nickname, 0, pin));
}
} }
public int calculateScore(float timeLeft, float maxTime) { public int calculateScore(float timeLeft, float maxTime) {
// Parameters to shape the S-curve // Parameters to shape the S-curve
float steepness = 10.0f; // Change this to make the curve steeper or shallower float steepness = 10.0f; // Change this to make the curve steeper or shallower
......
...@@ -92,6 +92,7 @@ public class GamePlayView { ...@@ -92,6 +92,7 @@ public class GamePlayView {
timeLeft = 0; timeLeft = 0;
isTimerRunning = false; // Stop the timer when it reaches 0 isTimerRunning = false; // Stop the timer when it reaches 0
// Handle time out logic // Handle time out logic
} }
} }
} }
...@@ -144,8 +145,9 @@ public class GamePlayView { ...@@ -144,8 +145,9 @@ public class GamePlayView {
letterBounds[i] = new Rectangle(x, y-120, 120, 120); letterBounds[i] = new Rectangle(x, y-120, 120, 120);
} }
// Draw time // Draw time
font.draw(sb, "Time: " + String.format("%.1f", timeLeft), cam.viewportWidth / 2 - 200, cam.viewportHeight - 200); font.draw(sb, "Time: " + String.format("%o", Math.round(timeLeft)), cam.viewportWidth / 2 - 200, cam.viewportHeight - 200);
sb.end(); // End SpriteBatch sb.end(); // End SpriteBatch
...@@ -244,6 +246,10 @@ public class GamePlayView { ...@@ -244,6 +246,10 @@ public class GamePlayView {
isTimerRunning = false; isTimerRunning = false;
} }
public boolean isTimerRunning() {
return isTimerRunning;
}
public void resetTimer(float newTime) { public void resetTimer(float newTime) {
timeLeft = newTime; timeLeft = newTime;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment