Fixed a merge issue.

#story[923] #bug #refactor
This commit is contained in:
Calum
2017-05-17 18:06:36 +12:00
parent 8a3a41294a
commit 45db731a60
2 changed files with 26 additions and 60 deletions
+2 -2
View File
@@ -62,8 +62,8 @@ public class App extends Application {
} }
//Change the StreamReceiver in this else block to change the default data source. //Change the StreamReceiver in this else block to change the default data source.
else{ else{
// sr = new StreamReceiver("localhost", 4949, "RaceStream"); sr = new StreamReceiver("localhost", 4949, "RaceStream");
sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream"); // sr = new StreamReceiver("livedata.americascup.com", 4941, "RaceStream");
} }
sr.start(); sr.start();
+24 -58
View File
@@ -222,33 +222,30 @@ public class BoatGroup extends RaceObject {
* on. * on.
*/ */
public void updatePosition(long timeInterval) { public void updatePosition(long timeInterval) {
//Calculate the movement of the boat. double dx = pixelVelocityX * timeInterval;
if (isMaximized) { double dy = pixelVelocityY * timeInterval;
double dx = pixelVelocityX * timeInterval; double rotation = rotationalVelocity * timeInterval;
double dy = pixelVelocityY * timeInterval; distanceTravelled += Math.abs(dx) + Math.abs(dy);
double rotation = rotationalVelocity * timeInterval; moveGroupBy(dx, dy, rotation);
distanceTravelled += Math.abs(dx) + Math.abs(dy); //Draw a new section of the trail every 20 pixels of movement.
moveGroupBy(dx, dy, rotation); if (distanceTravelled > 20) {
//Draw a new section of the trail every 20 pixels of movement. distanceTravelled = 0;
if (distanceTravelled > 20) { if (lastPoint != null) {
distanceTravelled = 0; Line l = new Line(
if (lastPoint != null) { lastPoint.getX(),
Line l = new Line( lastPoint.getY(),
lastPoint.getX(), boatPoly.getLayoutX(),
lastPoint.getY(), boatPoly.getLayoutY()
boatPoly.getLayoutX(), );
boatPoly.getLayoutY() l.getStrokeDashArray().setAll(3d, 7d);
); l.setStroke(boat.getColour());
l.getStrokeDashArray().setAll(3d, 7d); lineGroup.getChildren().add(l);
l.setStroke(boat.getColour()); }
lineGroup.getChildren().add(l); if (destinationSet) { //Only begin drawing after the first destination is set
} lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
if (destinationSet) { //Only begin drawing after the first destination is set
lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
}
} }
wake.updatePosition(timeInterval);
} }
wake.updatePosition(timeInterval);
} }
/** /**
@@ -265,28 +262,18 @@ public class BoatGroup extends RaceObject {
if (setToInitialLocation) { if (setToInitialLocation) {
destinationSet = true; destinationSet = true;
boat.setVelocity(groundSpeed); boat.setVelocity(groundSpeed);
if (currentRotation < 0) {
currentRotation = 360 - currentRotation;
}
double dx = newXValue - boatPoly.getLayoutX(); double dx = newXValue - boatPoly.getLayoutX();
double dy = newYValue - boatPoly.getLayoutY(); double dy = newYValue - boatPoly.getLayoutY();
//Check movement is reasonable. Assumes a 1000 * 1000 canvas
// if (Math.abs(dx) > 50 || Math.abs(dy) > 50) {
// dx = 0;
// dy = 0;
// moveTo(newXValue, newYValue);
// }
pixelVelocityX = dx / expectedUpdateInterval; pixelVelocityX = dx / expectedUpdateInterval;
pixelVelocityY = dy / expectedUpdateInterval; pixelVelocityY = dy / expectedUpdateInterval;
rotationalGoal = rotation; rotationalGoal = rotation;
calculateRotationalVelocity(); calculateRotationalVelocity();
if (Math.abs(rotationalVelocity) > 0.075) { if (Math.abs(rotationalVelocity) > 0.075) {
System.out.println("rotationalVelocity = " + rotationalVelocity); System.out.println("rotationalVelocity = " + rotationalVelocity);
rotationalVelocity = 0; rotationalVelocity = 0;
wakeGenerationDelay--;
} else {
wake.setRotationalVelocity(rotationalVelocity, boat.getVelocity());
rotateTo(rotationalGoal); rotateTo(rotationalGoal);
wake.rotate(rotationalGoal); wake.rotate(rotationalGoal);
} }
@@ -312,27 +299,6 @@ public class BoatGroup extends RaceObject {
} }
} }
//If minimized generate lines every 5 calls to set destination. //If minimized generate lines every 5 calls to set destination.
if (!isMaximized) {
setToInitialLocation = false;
wakeGenerationDelay = 2;
if (setCallCount-- == 0) {
setCallCount = 5;
if (lastPoint != null) {
Line l = new Line(
lastPoint.getX(),
lastPoint.getY(),
newXValue,
newYValue
);
l.getStrokeDashArray().setAll(3d, 7d);
l.setStroke(boatPoly.getFill());
lineStorage.add(l);
}
if (destinationSet) { //Only begin drawing after the first destination is set
lastPoint = new Point2D(newXValue, newYValue);
}
}
}
} }
public void setDestination(double newXValue, double newYValue, double groundSpeed, public void setDestination(double newXValue, double newYValue, double groundSpeed,