Implemented acceleration and full loading bars.

#story[1274]
This commit is contained in:
Kusal Ekanayake
2017-09-22 17:28:42 +12:00
parent b05580f018
commit 9f64b2380d
4 changed files with 19 additions and 12 deletions
@@ -461,17 +461,17 @@ public class GameState implements Runnable {
// TODO: 15/08/17 remove magic numbers from these equations. // TODO: 15/08/17 remove magic numbers from these equations.
if (yacht.getSailIn()) { if (yacht.getSailIn()) {
if (currentVelocity < maxBoatSpeed - 500) { if (currentVelocity < maxBoatSpeed - 500) {
yacht.changeVelocity(maxBoatSpeed / 100); yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAcceleration());
} else if (currentVelocity > maxBoatSpeed + 500) { } else if (currentVelocity > maxBoatSpeed + 500) {
yacht.changeVelocity(-currentVelocity / 200); yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration());
} else { } else {
yacht.setCurrentVelocity(maxBoatSpeed); yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAcceleration());
} }
} else { } else {
if (currentVelocity > 3000) { if (currentVelocity > 3000) {
yacht.changeVelocity(-currentVelocity / 200); yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration());
} else if (currentVelocity > 100) { } else if (currentVelocity > 100) {
yacht.changeVelocity(-currentVelocity / 50); yacht.changeVelocity((-currentVelocity / 50) * yacht.getAcceleration());
} else if (currentVelocity <= 100) { } else if (currentVelocity <= 100) {
yacht.setCurrentVelocity(0d); yacht.setCurrentVelocity(0d);
} }
+8 -1
View File
@@ -11,6 +11,7 @@ import seng302.utilities.GeoUtility;
import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType;
import java.util.HashMap; import java.util.HashMap;
import java.util.Objects;
/** /**
* Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses) * Yacht class for the racing boat. <p> Class created to store more variables (eg. boat statuses)
@@ -25,6 +26,7 @@ public class ServerYacht {
private String boatType; private String boatType;
private Double turnStep = 10.0; private Double turnStep = 10.0;
private Double maxSpeedMultiplier = 1.0; private Double maxSpeedMultiplier = 1.0;
private Double acceleration = 1.0;
private Integer sourceId; private Integer sourceId;
private String hullID; //matches HullNum in the XML spec. private String hullID; //matches HullNum in the XML spec.
private String shortName; private String shortName;
@@ -423,10 +425,11 @@ public class ServerYacht {
public void setBoatType(String boatType) { public void setBoatType(String boatType) {
BoatMeshType boatMeshType; BoatMeshType boatMeshType;
for (BoatMeshType boatMesh: BoatMeshType.values()) { for (BoatMeshType boatMesh: BoatMeshType.values()) {
if (boatType == boatMesh.toString()) { if (Objects.equals(boatType, boatMesh.toString())) {
boatMeshType = boatMesh; boatMeshType = boatMesh;
turnStep = boatMeshType.turnStep; turnStep = boatMeshType.turnStep;
maxSpeedMultiplier = boatMeshType.maxSpeedMultiplier; maxSpeedMultiplier = boatMeshType.maxSpeedMultiplier;
acceleration = boatMeshType.accelerationMultiplier;
} }
} }
this.boatType = boatType; this.boatType = boatType;
@@ -436,6 +439,10 @@ public class ServerYacht {
return maxSpeedMultiplier; return maxSpeedMultiplier;
} }
public Double getAcceleration(){
return acceleration;
}
public String getBoatType() { public String getBoatType() {
return boatType; return boatType;
} }
@@ -56,9 +56,9 @@ public class BoatCustomizeController implements Initializable{
private ClientToServerThread socketThread; private ClientToServerThread socketThread;
private LobbyController lobbyController; private LobbyController lobbyController;
private BoatMeshType currentBoat; private BoatMeshType currentBoat;
private static Double maxSpeedMultiplier = 1.0; private Double maxSpeedMultiplier = 1.0;
private static Double maxTurnRate = 10.0; private Double maxTurnRate = 10.0;
private static Double maxAcceleration = 2.0; private Double maxAcceleration = 1.0;
@Override @Override
public void initialize(URL location, ResourceBundle resources) { public void initialize(URL location, ResourceBundle resources) {
@@ -7,11 +7,11 @@ package seng302.visualiser.fxObjects.assets_3D;
*/ */
public enum BoatMeshType { public enum BoatMeshType {
DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false, 1.5, 1.0, 5.0), DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false, 1.7, 1.0, 5.0),
CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl", CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl",
0.997, null, false, 1.0, 1.0, 10.0), 0.997, null, false, 1.0, 1.4, 10.0),
PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl", PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl",
-0.5415, "pirateship_frontsail.stl", true, 1.2, 1.0, 7.0); -0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 6.0);
final String hullFile, mastFile, sailFile, jibFile; final String hullFile, mastFile, sailFile, jibFile;
final double mastOffset, sailOffset; final double mastOffset, sailOffset;