Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Haoming Yin
2017-07-26 23:32:32 +12:00
3 changed files with 27 additions and 50 deletions
@@ -250,12 +250,9 @@ public class CanvasController {
// some raceObjects will have multiple ID's (for instance gate marks) // some raceObjects will have multiple ID's (for instance gate marks)
//checking if the current "ID" has any updates associated with it //checking if the current "ID" has any updates associated with it
if (ClientPacketParser.boatLocations.containsKey(boatGroup.getRaceId())) { if (ClientPacketParser.boatLocations.containsKey(boatGroup.getRaceId())) {
if (boatGroup.isStopped()) {
updateBoatGroup(boatGroup); updateBoatGroup(boatGroup);
} }
} }
boatGroup.move();
}
for (MarkGroup markGroup : markGroups) { for (MarkGroup markGroup : markGroups) {
for (Long id : markGroup.getRaceIds()) { for (Long id : markGroup.getRaceIds()) {
if (ClientPacketParser.markLocations.containsKey(id)) { if (ClientPacketParser.markLocations.containsKey(id)) {
+25 -45
View File
@@ -163,18 +163,33 @@ public class BoatGroup extends Group {
boatPoly.getTransforms().setAll(new Rotate(rotation)); boatPoly.getTransforms().setAll(new Rotate(rotation));
} }
public void move() { /**
double dx = xIncrement * framesToMove; * Sets the destination of the boat and the headng it should have once it reaches
double dy = yIncrement * framesToMove; *
* @param newXValue The X co-ordinate the boat needs to move to.
* @param newYValue The Y co-ordinate the boat needs to move to.
* @param rotation Rotation to move graphics to.
* @param timeValid the time the position values are valid for
*/
public void setDestination(double newXValue, double newYValue, double rotation,
double groundSpeed, long timeValid, double frameRate) {
distanceTravelled += Math.abs(dx) + Math.abs(dy); destinationSet = true;
moveGroupBy(xIncrement, yIncrement); Double dx = Math.abs(boatPoly.getLayoutX() - newXValue);
framesToMove = framesToMove - 1; Double dy = Math.abs(boatPoly.getLayoutY() - newYValue);
moveTo(newXValue, newYValue, rotation);
if (framesToMove <= 0) {
isStopped = true; rotateTo(rotation);
} wake.setRotation(rotation, groundSpeed);
if (distanceTravelled > 70 && isPlayer) { boat.setVelocity(groundSpeed);
isStopped = false;
lastRotation = rotation;
boatAnnotations.update();
distanceTravelled += Math.sqrt((dx * dx) + (dy * dy));
if (distanceTravelled > 10 && isPlayer) {
distanceTravelled = 0d; distanceTravelled = 0d;
if (lastPoint != null) { if (lastPoint != null) {
@@ -190,45 +205,10 @@ public class BoatGroup extends Group {
l.setCacheHint(CacheHint.SPEED); l.setCacheHint(CacheHint.SPEED);
lineGroup.getChildren().add(l); lineGroup.getChildren().add(l);
} }
if (destinationSet) { if (destinationSet) {
lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY()); lastPoint = new Point2D(boatPoly.getLayoutX(), boatPoly.getLayoutY());
} }
} }
// wake.updatePosition();
}
/**
* Sets the destination of the boat and the headng it should have once it reaches
*
* @param newXValue The X co-ordinate the boat needs to move to.
* @param newYValue The Y co-ordinate the boat needs to move to.
* @param rotation Rotation to move graphics to.
* @param timeValid the time the position values are valid for
*/
public void setDestination(double newXValue, double newYValue, double rotation,
double groundSpeed, long timeValid, double frameRate) {
if (lastTimeValid == 0) {
lastTimeValid = timeValid - 200;
moveTo(newXValue, newYValue, rotation);
}
framesToMove = Math.round((frameRate / (1000.0f / (timeValid - lastTimeValid))));
double dx = newXValue - boatPoly.getLayoutX();
double dy = newYValue - boatPoly.getLayoutY();
xIncrement = dx / framesToMove;
yIncrement = dy / framesToMove;
destinationSet = true;
rotateTo(rotation);
// wake.rotate(rotation);
wake.setRotation(rotation, groundSpeed);
boat.setVelocity(groundSpeed);
lastTimeValid = timeValid;
isStopped = false;
lastRotation = rotation;
boatAnnotations.update();
} }
@@ -23,7 +23,7 @@ import java.util.logging.Logger;
public class MainServerThread extends Observable implements Runnable, ClientConnectionDelegate{ public class MainServerThread extends Observable implements Runnable, ClientConnectionDelegate{
private static final int PORT = 4942; private static final int PORT = 4942;
private static final Integer CLIENT_UPDATES_PER_SECOND = 5; private static final Integer CLIENT_UPDATES_PER_SECOND = 10;
private static final int LOG_LEVEL = 1; private static final int LOG_LEVEL = 1;
private Thread thread; private Thread thread;