mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Fixed bug which caused boats to all travel to the same position.
This commit is contained in:
@@ -166,20 +166,28 @@ public class CanvasController {
|
|||||||
//descending = nextMark.getY() > boatGroup.getLayoutY();
|
//descending = nextMark.getY() > boatGroup.getLayoutY();
|
||||||
//leftToRight = nextMark.getX() < boatGroup.getLayoutX();
|
//leftToRight = nextMark.getX() < boatGroup.getLayoutX();
|
||||||
|
|
||||||
boatGroup.updatePosition(1000 / 6);
|
boatGroup.updatePosition(1000 / 60);
|
||||||
Point3D p = StreamParser.boatPositions.get((long)boatGroup.getBoat().getId());
|
Point3D p = StreamParser.boatPositions.get((long)boatGroup.getBoat().getId());
|
||||||
//System.out.println("boatGroup = " + boatGroup.getBoat().getId());
|
//System.out.println("boatGroup = " + boatGroup.getBoat().getId());
|
||||||
//System.out.println("StreamParser.boatPositions.toString() = " + StreamParser.boatPositions.toString());
|
//System.out.println("StreamParser.boatPositions.toString() = " + StreamParser.boatPositions.toString());
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
Point2D p2d = latLonToXY(p.getX(), p.getY());
|
Point2D p2d = latLonToXY(p.getX(), p.getY());
|
||||||
System.out.println("p2d = " + p2d);
|
//System.out.println("p2d = " + p2d);
|
||||||
if (!boatGroup.getBoat().isSamePos(p2d)) {
|
if (!boatGroup.getBoat().isSamePos(p2d)) {
|
||||||
//System.out.println("p.toString() = " + p.toString());
|
//System.out.println("p.toString() = " + p.toString());
|
||||||
double heading = 360.0 / 0xffff * p.getZ();
|
double heading = 360.0 / 0xffff * p.getZ();
|
||||||
System.out.println("heading = " + heading);
|
//System.out.println("heading = " + heading);
|
||||||
boatGroup.setDestination(p.getX(), p.getY(), heading);
|
|
||||||
|
|
||||||
|
|
||||||
|
boatGroup.setDestination(p2d.getX(), p2d.getY(), heading);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//boatGroup.setDestination(p2d.getX(), p2d.getY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (descending && nextMark.getY() < boatGroup.getLayoutY()) {
|
// if (descending && nextMark.getY() < boatGroup.getLayoutY()) {
|
||||||
// currentRaceMarker[boatIndex]++;
|
// currentRaceMarker[boatIndex]++;
|
||||||
// boatGroup.setDestination(
|
// boatGroup.setDestination(
|
||||||
@@ -281,7 +289,7 @@ public class CanvasController {
|
|||||||
for (Boat boat : boats) {
|
for (Boat boat : boats) {
|
||||||
BoatGroup boatGroup = new BoatGroup(boat, Colors.getColor());
|
BoatGroup boatGroup = new BoatGroup(boat, Colors.getColor());
|
||||||
boatGroup.moveBoatTo(startingX, startingY, 0d);
|
boatGroup.moveBoatTo(startingX, startingY, 0d);
|
||||||
// boatGroup.setDestination(firstMarkX, firstMarkY);
|
boatGroup.setDestination(firstMarkX, firstMarkY);
|
||||||
boatGroup.forceRotation();
|
boatGroup.forceRotation();
|
||||||
group.getChildren().add(boatGroup);
|
group.getChildren().add(boatGroup);
|
||||||
boatGroups.add(boatGroup);
|
boatGroups.add(boatGroup);
|
||||||
|
|||||||
@@ -123,8 +123,30 @@ public class BoatGroup extends Group{
|
|||||||
//this.destinationX = newXValue;
|
//this.destinationX = newXValue;
|
||||||
//this.destinationY = newYValue;
|
//this.destinationY = newYValue;
|
||||||
this.rotationalGoal = rotation;
|
this.rotationalGoal = rotation;
|
||||||
|
// if (super.getLayoutY() >= newYValue && super.getLayoutX() <= newXValue)
|
||||||
|
// rotationalGoal = 90 - rotationalGoal;
|
||||||
|
// else if (super.getLayoutY() < newYValue && super.getLayoutX() <= newXValue)
|
||||||
|
// rotationalGoal = 90 + rotationalGoal;
|
||||||
|
// else if (super.getLayoutY() >= newYValue && super.getLayoutX() > newXValue)
|
||||||
|
// rotationalGoal = 270 + rotationalGoal;
|
||||||
|
// else
|
||||||
|
// rotationalGoal = 270 - rotationalGoal;
|
||||||
|
// if (Math.abs(360 - rotationalGoal + currentRotation) < Math.abs(rotationalGoal - currentRotation)) {
|
||||||
|
// System.out.println("ROTATE");
|
||||||
|
// this.rotationalVelocity = (360 - rotationalGoal + currentRotation) / expectedUpdateInterval;
|
||||||
|
// } else {
|
||||||
|
// this.rotationalVelocity = (rotationalGoal - currentRotation) / expectedUpdateInterval;
|
||||||
|
// }
|
||||||
|
if (Math.abs(rotationalGoal - currentRotation) > 180) {
|
||||||
|
if (rotationalGoal - currentRotation >= 0) {
|
||||||
|
this.rotationalVelocity = ((rotationalGoal - currentRotation) - 360) / expectedUpdateInterval;
|
||||||
|
} else {
|
||||||
|
this.rotationalVelocity = (360 + (rotationalGoal - currentRotation)) / expectedUpdateInterval;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.rotationalVelocity = (rotationalGoal - currentRotation) / expectedUpdateInterval;
|
this.rotationalVelocity = (rotationalGoal - currentRotation) / expectedUpdateInterval;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setDestination (double newXValue, double newYValue) {
|
public void setDestination (double newXValue, double newYValue) {
|
||||||
this.pixelVelocityX = (newXValue - super.getLayoutX()) / expectedUpdateInterval;
|
this.pixelVelocityX = (newXValue - super.getLayoutX()) / expectedUpdateInterval;
|
||||||
@@ -146,10 +168,12 @@ public class BoatGroup extends Group{
|
|||||||
rotationalGoal = 270 + rotationalGoal;
|
rotationalGoal = 270 + rotationalGoal;
|
||||||
else
|
else
|
||||||
rotationalGoal = 270 - rotationalGoal;
|
rotationalGoal = 270 - rotationalGoal;
|
||||||
// TODO: 25/04/2017 cir27 - Verify this logic is correct. Want to produce the shortest path.
|
if (Math.abs(rotationalGoal - currentRotation) > 180) {
|
||||||
if (Math.abs(360 - rotationalGoal + currentRotation) < Math.abs(rotationalGoal - currentRotation)) {
|
if (rotationalGoal - currentRotation >= 0) {
|
||||||
System.out.println("ROTATE");
|
this.rotationalVelocity = ((rotationalGoal - currentRotation) - 360) / expectedUpdateInterval;
|
||||||
this.rotationalVelocity = (360 - rotationalGoal + currentRotation) / expectedUpdateInterval;
|
} else {
|
||||||
|
this.rotationalVelocity = (360 + (rotationalGoal - currentRotation)) / expectedUpdateInterval;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.rotationalVelocity = (rotationalGoal - currentRotation) / expectedUpdateInterval;
|
this.rotationalVelocity = (rotationalGoal - currentRotation) / expectedUpdateInterval;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user