Removed unnecessary constant

This commit is contained in:
Calum
2017-05-17 17:23:10 +12:00
parent c63c8e4d73
commit 7c39368126
3 changed files with 25 additions and 25 deletions
+21 -22
View File
@@ -48,10 +48,6 @@ public class BoatGroup extends RaceObject{
private boolean isMaximized= true; private boolean isMaximized= true;
private List<Line> lineStorage = new ArrayList<>(); private List<Line> lineStorage = new ArrayList<>();
private int setCallCount = 5; private int setCallCount = 5;
private int frameCount = 90;
private double lastX;
private double lastY;
/** /**
* Creates a BoatGroup with the default triangular boat polygon. * Creates a BoatGroup with the default triangular boat polygon.
@@ -126,8 +122,8 @@ public class BoatGroup extends RaceObject{
* @param dy The amount to move the Y coordinate by * @param dy The amount to move the Y coordinate by
*/ */
public void moveGroupBy(double dx, double dy, double rotation) { public void moveGroupBy(double dx, double dy, double rotation) {
boatPoly.setLayoutX(lastX + dx); boatPoly.setLayoutX(boatPoly.getLayoutX() + dx);
boatPoly.setLayoutY(lastY + dy); boatPoly.setLayoutY(boatPoly.getLayoutY() + dy);
teamNameObject.setLayoutX(teamNameObject.getLayoutX() + dx); teamNameObject.setLayoutX(teamNameObject.getLayoutX() + dx);
teamNameObject.setLayoutY(teamNameObject.getLayoutY() + dy); teamNameObject.setLayoutY(teamNameObject.getLayoutY() + dy);
velocityObject.setLayoutX(velocityObject.getLayoutX() + dx); velocityObject.setLayoutX(velocityObject.getLayoutX() + dx);
@@ -178,21 +174,26 @@ public class BoatGroup extends RaceObject{
distanceTravelled += Math.abs(dx) + Math.abs(dy); distanceTravelled += Math.abs(dx) + Math.abs(dy);
moveGroupBy(dx, dy, rotation); moveGroupBy(dx, dy, rotation);
//Draw a new section of the trail every 20 pixels of movement. //Draw a new section of the trail every 20 pixels of movement.
if (frameCount-- == 0) { if (distanceTravelled > 20) {
frameCount = (int) (300 - boat.getVelocity() * 10); distanceTravelled = 0;
if (lastPoint != null) { if (lastPoint != null) {
Line l = new Line( Line l = new Line(
lastPoint.getX(), lastPoint.getX() * 3 - 1000,
lastPoint.getY(), lastPoint.getY() * 3 - 1000,
lastX, boatPoly.getLayoutX() * 3 - 1000,
lastY boatPoly.getLayoutY() * 3 - 1000
); );
l.getStrokeDashArray().setAll(3d, 7d); l.getStrokeDashArray().setAll(3d, 7d);
l.setStroke(boatPoly.getFill()); l.setStroke(boatPoly.getFill());
if (lastPoint.getX() * 3 - 1000 < 0 || lastPoint.getY() * 3 - 1000 < 0 || boatPoly.getLayoutX() * 3 - 1000 < 0 || boatPoly.getLayoutY() * 3 - 1000 < 0)
l.setVisible(false);
else
l.setVisible(true);
lineGroup.getChildren().add(l); lineGroup.getChildren().add(l);
} }
if (destinationSet) { //Only begin drawing after the first destination is set if (destinationSet) { //Only begin drawing after the first destination is set
lastPoint = new Point2D(lastX, lastY); lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
} }
} }
wake.updatePosition(timeInterval); wake.updatePosition(timeInterval);
@@ -213,8 +214,8 @@ public class BoatGroup extends RaceObject{
boat.setVelocity(groundSpeed); boat.setVelocity(groundSpeed);
if (currentRotation < 0) if (currentRotation < 0)
currentRotation = 360 - currentRotation; currentRotation = 360 - currentRotation;
double dx = newXValue - lastX; double dx = newXValue - boatPoly.getLayoutX();
double dy = newYValue - lastY; double dy = newYValue - boatPoly.getLayoutY();
//Check movement is reasonable. Assumes a 1000 * 1000 canvas //Check movement is reasonable. Assumes a 1000 * 1000 canvas
// if (Math.abs(dx) > 50 || Math.abs(dy) > 50) { // if (Math.abs(dx) > 50 || Math.abs(dy) > 50) {
// dx = 0; // dx = 0;
@@ -224,8 +225,6 @@ public class BoatGroup extends RaceObject{
pixelVelocityX = dx / expectedUpdateInterval; pixelVelocityX = dx / expectedUpdateInterval;
pixelVelocityY = dy / expectedUpdateInterval; pixelVelocityY = dy / expectedUpdateInterval;
lastX = newXValue;
lastY = newYValue;
rotationalGoal = rotation; rotationalGoal = rotation;
calculateRotationalVelocity(); calculateRotationalVelocity();
if (Math.abs(rotationalVelocity) > 0.075) { if (Math.abs(rotationalVelocity) > 0.075) {
@@ -250,10 +249,10 @@ public class BoatGroup extends RaceObject{
setCallCount = 5; setCallCount = 5;
if (lastPoint != null) { if (lastPoint != null) {
Line l = new Line( Line l = new Line(
lastPoint.getX(), lastPoint.getX() * 1.5,
lastPoint.getY(), lastPoint.getY() * 1.5,
newXValue, newXValue * 1.5,
newYValue newYValue * 1.5
); );
l.getStrokeDashArray().setAll(3d, 7d); l.getStrokeDashArray().setAll(3d, 7d);
l.setStroke(boatPoly.getFill()); l.setStroke(boatPoly.getFill());
@@ -273,7 +272,7 @@ public class BoatGroup extends RaceObject{
double rotation = Math.abs( double rotation = Math.abs(
Math.toDegrees( Math.toDegrees(
Math.atan( Math.atan(
(newYValue - lastY) / (newXValue - lastX) (newYValue - boatPoly.getLayoutY()) / (newXValue - boatPoly.getLayoutX())
) )
) )
); );
+1 -1
View File
@@ -18,7 +18,7 @@ class Wake extends Group {
//The total possible difference between the first wake and the last. Increasing/Decreasing this will make wakes fan out more/less. //The total possible difference between the first wake and the last. Increasing/Decreasing this will make wakes fan out more/less.
private final double MAX_DIFF = 75; private final double MAX_DIFF = 75;
//Increasing/decreasing this will alter the speed that wakes converge when the heading stop changing. Anything over about 1500 may cause oscillation. //Increasing/decreasing this will alter the speed that wakes converge when the heading stop changing. Anything over about 1500 may cause oscillation.
private final int UNIFICATION_SPEED = 500; private final int UNIFICATION_SPEED = 750;
private Arc[] arcs = new Arc[numWakes]; private Arc[] arcs = new Arc[numWakes];
@@ -17,6 +17,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.PriorityBlockingQueue;
/** /**
@@ -36,8 +37,8 @@ public class StreamParser extends Thread{
private static boolean raceFinished = false; private static boolean raceFinished = false;
private static boolean streamStatus = false; private static boolean streamStatus = false;
private static long timeSinceStart = -1; private static long timeSinceStart = -1;
private static Map<Integer, Yacht> boats = new HashMap<>(); private static Map<Integer, Yacht> boats = new ConcurrentHashMap<>();
private static Map<Long, Yacht> boatsPos = new TreeMap<>(); private static Map<Long, Yacht> boatsPos = new ConcurrentSkipListMap<>();
private static double windDirection = 0; private static double windDirection = 0;
private static String currentTimeString; private static String currentTimeString;
private static boolean appRunning; private static boolean appRunning;