Track scales with time scale #Pair[jjg64, zwu18] #Story[758]
This commit is contained in:
@@ -30,7 +30,9 @@ public class BoatInRace extends Boat {
|
||||
|
||||
private Queue<TrackPoint> track = new ConcurrentLinkedQueue<>();
|
||||
private long nextValidTime = 0;
|
||||
private final int TRACK_POINT_TIME_INTERVAL = 1000; // every 1 seconds
|
||||
|
||||
private static final float BASE_TRACK_POINT_TIME_INTERVAL = 5000;
|
||||
private static float trackPointTimeInterval = 5000; // every 1 seconds
|
||||
private final int TRACK_POINT_LIMIT = 10;
|
||||
private boolean trackVisible = true;
|
||||
|
||||
@@ -269,8 +271,8 @@ public class BoatInRace extends Boat {
|
||||
Boolean added = System.currentTimeMillis() >= nextValidTime;
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (added && this.started) {
|
||||
nextValidTime = currentTime + TRACK_POINT_TIME_INTERVAL;
|
||||
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * TRACK_POINT_TIME_INTERVAL));
|
||||
nextValidTime = currentTime + (long) trackPointTimeInterval;
|
||||
track.add(new TrackPoint(coordinate, currentTime, TRACK_POINT_LIMIT * (long) trackPointTimeInterval));
|
||||
}
|
||||
return added;
|
||||
}
|
||||
@@ -299,4 +301,12 @@ public class BoatInRace extends Boat {
|
||||
public void setTrackVisible(boolean trackVisible) {
|
||||
this.trackVisible = trackVisible;
|
||||
}
|
||||
|
||||
public static float getBaseTrackPointTimeInterval() {
|
||||
return BASE_TRACK_POINT_TIME_INTERVAL;
|
||||
}
|
||||
|
||||
public static void setTrackPointTimeInterval(float value) {
|
||||
trackPointTimeInterval = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class Race implements Runnable {
|
||||
protected int scaleFactor;
|
||||
|
||||
private int SLEEP_TIME = 100; //time in milliseconds to pause in a paced loop
|
||||
protected int PRERACE_TIME = 120000; //time in milliseconds to pause during pre-race
|
||||
protected int PRERACE_TIME = 0; //120000; //time in milliseconds to pause during pre-race
|
||||
private boolean timerEnabled = true; //boolean to determine if timer is ran
|
||||
|
||||
/**
|
||||
@@ -72,6 +72,7 @@ public abstract class Race implements Runnable {
|
||||
String name = officialStart.getName();
|
||||
Marker endMarker = officialStart.getEndMarker();
|
||||
|
||||
BoatInRace.setTrackPointTimeInterval(BoatInRace.getBaseTrackPointTimeInterval() / scaleFactor);
|
||||
|
||||
ArrayList<Marker> startMarkers = getSpreadStartingPositions();
|
||||
for (int i = 0; i < startingBoats.size(); i++) {
|
||||
|
||||
@@ -39,6 +39,9 @@ public class ResizableRaceCanvas extends Canvas {
|
||||
*/
|
||||
public void setBoats(BoatInRace[] boats) {
|
||||
this.boats = boats;
|
||||
for (BoatInRace boat : boats) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
public ResizableRaceCanvas(RaceMap map) {
|
||||
|
||||
Reference in New Issue
Block a user