Updated velocity in yacht constructor so the boat can be seen properly working for test purposes

This commit is contained in:
William Muir
2017-07-24 16:47:17 +12:00
parent 526c12127f
commit 07cebb6c5b
3 changed files with 18 additions and 2 deletions
+16 -2
View File
@@ -110,7 +110,7 @@ public class Yacht {
this.sailIn = false;
this.location = new GeoPoint(57.6679590, 11.8503233);
this.heading = 0.0;
this.velocity = 0.0;
this.velocity = 50000.0;
}
/**
@@ -155,6 +155,7 @@ public class Yacht {
public void adjustHeading(Double amount) {
lastHeading = heading;
// TODO: 24/07/17 wmu16 - '%' in java does remainder, we need modulo. All this must be changed here, this is why we have neg values!
heading = (heading + amount) % 360.0;
}
@@ -188,7 +189,20 @@ public class Yacht {
}
public void turnDownwind() {
if ((heading - GameState.windDirection) % 360 < 180) {
Double normalizedHeading = (heading - GameState.windDirection) % 360;
if (normalizedHeading == 0) {
if (lastHeading < 180) {
adjustHeading(TURN_STEP);
} else {
adjustHeading(-TURN_STEP);
}
} else if (normalizedHeading == 180) {
if (lastHeading < 180) {
adjustHeading(-TURN_STEP);
} else {
adjustHeading(TURN_STEP);
}
} else if (normalizedHeading < 180) {
adjustHeading(TURN_STEP);
} else {
adjustHeading(-TURN_STEP);