Fixed bug which caused boats to all travel to the same position.

This commit is contained in:
Calum
2017-04-26 19:19:03 +12:00
parent c776d22941
commit 95bafdc0d1
2 changed files with 42 additions and 10 deletions
@@ -166,20 +166,28 @@ public class CanvasController {
//descending = nextMark.getY() > boatGroup.getLayoutY();
//leftToRight = nextMark.getX() < boatGroup.getLayoutX();
boatGroup.updatePosition(1000 / 6);
boatGroup.updatePosition(1000 / 60);
Point3D p = StreamParser.boatPositions.get((long)boatGroup.getBoat().getId());
//System.out.println("boatGroup = " + boatGroup.getBoat().getId());
//System.out.println("StreamParser.boatPositions.toString() = " + StreamParser.boatPositions.toString());
if (p != null) {
Point2D p2d = latLonToXY(p.getX(), p.getY());
System.out.println("p2d = " + p2d);
//System.out.println("p2d = " + p2d);
if (!boatGroup.getBoat().isSamePos(p2d)) {
//System.out.println("p.toString() = " + p.toString());
double heading = 360.0 / 0xffff * p.getZ();
System.out.println("heading = " + heading);
boatGroup.setDestination(p.getX(), p.getY(), heading);
//System.out.println("heading = " + heading);
boatGroup.setDestination(p2d.getX(), p2d.getY(), heading);
//boatGroup.setDestination(p2d.getX(), p2d.getY());
}
}
// if (descending && nextMark.getY() < boatGroup.getLayoutY()) {
// currentRaceMarker[boatIndex]++;
// boatGroup.setDestination(
@@ -281,7 +289,7 @@ public class CanvasController {
for (Boat boat : boats) {
BoatGroup boatGroup = new BoatGroup(boat, Colors.getColor());
boatGroup.moveBoatTo(startingX, startingY, 0d);
// boatGroup.setDestination(firstMarkX, firstMarkY);
boatGroup.setDestination(firstMarkX, firstMarkY);
boatGroup.forceRotation();
group.getChildren().add(boatGroup);
boatGroups.add(boatGroup);