|
|
|
@ -28,8 +28,8 @@ public abstract class Race implements Runnable {
|
|
|
|
protected int scaleFactor;
|
|
|
|
protected int scaleFactor;
|
|
|
|
|
|
|
|
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
|
|
|
protected int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
|
|
|
|
protected int PRERACE_TIME = 5000; //time in milliseconds to pause during pre-race
|
|
|
|
private boolean timerEnabled = true;
|
|
|
|
private boolean timerEnabled = true; //boolean to determine if timer is ran
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initailiser for Race
|
|
|
|
* Initailiser for Race
|
|
|
|
@ -148,7 +148,7 @@ public abstract class Race implements Runnable {
|
|
|
|
long remainingSeconds;
|
|
|
|
long remainingSeconds;
|
|
|
|
long hours;
|
|
|
|
long hours;
|
|
|
|
|
|
|
|
|
|
|
|
currentTimeInSeconds = (totalTimeElapsed / 1000) * scaleFactor;
|
|
|
|
currentTimeInSeconds = (totalTimeElapsed * scaleFactor)/ 1000;
|
|
|
|
minutes = currentTimeInSeconds / 60;
|
|
|
|
minutes = currentTimeInSeconds / 60;
|
|
|
|
remainingSeconds = currentTimeInSeconds % 60;
|
|
|
|
remainingSeconds = currentTimeInSeconds % 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
hours = minutes / 60;
|
|
|
|
@ -183,13 +183,11 @@ public abstract class Race implements Runnable {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void simulateRace() {
|
|
|
|
private void simulateRace() {
|
|
|
|
|
|
|
|
|
|
|
|
System.setProperty("javafx.animation.fullspeed", "true");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new AnimationTimer() {
|
|
|
|
new AnimationTimer() {
|
|
|
|
|
|
|
|
|
|
|
|
long timeRaceStarted = System.currentTimeMillis();
|
|
|
|
long timeRaceStarted = System.currentTimeMillis(); //start time of loop
|
|
|
|
int fps = 0;
|
|
|
|
int fps = 0; //init fps value
|
|
|
|
long timeCurrent = System.currentTimeMillis();
|
|
|
|
long timeCurrent = System.currentTimeMillis(); //current time
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void handle(long arg0) {
|
|
|
|
public void handle(long arg0) {
|
|
|
|
@ -211,6 +209,11 @@ public abstract class Race implements Runnable {
|
|
|
|
if (controller != null) controller.updateMap(startingBoats);
|
|
|
|
if (controller != null) controller.updateMap(startingBoats);
|
|
|
|
if (timerEnabled)
|
|
|
|
if (timerEnabled)
|
|
|
|
updateTime(calcTimer());
|
|
|
|
updateTime(calcTimer());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//Exit animation timer
|
|
|
|
|
|
|
|
updateTime(calcTimer());
|
|
|
|
|
|
|
|
updateFPS(0); //race ended so fps = 0
|
|
|
|
|
|
|
|
stop(); //exit animation timer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fps++;
|
|
|
|
fps++;
|
|
|
|
if ((System.currentTimeMillis()-timeCurrent) > 1000){
|
|
|
|
if ((System.currentTimeMillis()-timeCurrent) > 1000){
|
|
|
|
|