From dd43097677a37f546706273ff48e17bafab91c13 Mon Sep 17 00:00:00 2001 From: Peter Galloway Date: Tue, 26 Sep 2017 17:07:55 +1300 Subject: [PATCH] the boat can now turn after snapping to starboard vmg #story[1273] --- src/main/java/seng302/model/ServerYacht.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/seng302/model/ServerYacht.java b/src/main/java/seng302/model/ServerYacht.java index 5822b248..f7cdaeba 100644 --- a/src/main/java/seng302/model/ServerYacht.java +++ b/src/main/java/seng302/model/ServerYacht.java @@ -156,11 +156,11 @@ public class ServerYacht { /** * Enables the boats auto pilot feature, which will move the boat towards a given heading. * - * @param thisHeading The heading to move the boat towards. + * @param newHeading The heading to move the boat towards. */ - private void setAutoPilot(Double thisHeading) { + private void setAutoPilot(Double newHeading) { isAuto = true; - autoHeading = thisHeading; + autoHeading = newHeading; } /** @@ -178,8 +178,9 @@ public class ServerYacht { if (isAuto) { turnTowardsHeading(autoHeading); if (Math.abs(heading - autoHeading) - <= turnStep) { //Cancel when within 1 turn step of target. + <= turnStep*1.5) { isAuto = false; + setHeading(autoHeading); } } } @@ -265,7 +266,7 @@ public class ServerYacht { // Take optimal heading and turn into a boat heading rather than a wind heading. optimalHeading = - optimalHeading + GameState.getWindDirection(); + (optimalHeading + GameState.getWindDirection()) % 360; setAutoPilot(optimalHeading); }