mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Updated velocity in yacht constructor so the boat can be seen properly working for test purposes
This commit is contained in:
@@ -368,6 +368,7 @@ public class ClientPacketParser {
|
||||
//Converts the double to a usable lat/lon
|
||||
double lat = ((180d * (double) rawLat) / Math.pow(2, 31));
|
||||
double lon = ((180d * (double) rawLon) / Math.pow(2, 31));
|
||||
// System.out.println("[CLIENT] Lat: " + lat + " Lon: " + lon);
|
||||
long heading = bytesToLong(Arrays.copyOfRange(payload, 28, 30));
|
||||
double groundSpeed = bytesToLong(Arrays.copyOfRange(payload, 38, 40)) / 1000.0;
|
||||
//type 1 is a racing yacht and type 3 is a mark, needed for updating positions of the mark and boat
|
||||
|
||||
@@ -346,6 +346,7 @@ public class ServerToClientThread implements Runnable {
|
||||
private void sendBoatLocationPackets(){
|
||||
ArrayList<Yacht> yachts = new ArrayList<>(GameState.getYachts().values());
|
||||
for (Yacht yacht: yachts){
|
||||
// System.out.println("[SERVER] Lat: " + yacht.getLocation().getLat() + " Lon: " + yacht.getLocation().getLng());
|
||||
BoatLocationMessage boatLocationMessage = new BoatLocationMessage(sourceId, getSeqNo(), yacht.getLocation().getLat(), yacht.getLocation().getLng(), yacht.getHeading(), (long) yacht.getVelocity());
|
||||
sendMessage(boatLocationMessage);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user