mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Documented some RaceObject classes.
#documentation
This commit is contained in:
@@ -23,7 +23,6 @@ public class BoatGroup extends RaceObject{
|
||||
private static final double BOAT_HEIGHT = 15d;
|
||||
private static final double BOAT_WIDTH = 10d;
|
||||
private static final int LINE_INTERVAL = 30;
|
||||
private static double expectedUpdateInterval = 200;
|
||||
private double framesForNewLine = 0;
|
||||
private boolean destinationSet;
|
||||
private Point2D lastPoint;
|
||||
@@ -56,6 +55,7 @@ public class BoatGroup extends RaceObject{
|
||||
*/
|
||||
public BoatGroup (Boat boat, Color color, double... points)
|
||||
{
|
||||
this.boat = boat;
|
||||
initChildren(color, points);
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class BoatGroup extends RaceObject{
|
||||
|
||||
/**
|
||||
* Updates the position of all graphics in the BoatGroup based off of the given time interval.
|
||||
* @param timeInterval The interval, in microseconds, the boat should update it's position based on.
|
||||
* @param timeInterval The interval, in milliseconds, the boat should update it's position based on.
|
||||
*/
|
||||
public void updatePosition (long timeInterval) {
|
||||
//Calculate the movement of the boat.
|
||||
@@ -249,6 +249,12 @@ public class BoatGroup extends RaceObject{
|
||||
return boat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this BoatGroup contains at least one of the given IDs.
|
||||
*
|
||||
* @param raceIds The ID's to check the BoatGroup for.
|
||||
* @return True if the BoatGroup contains at east one of the given IDs, false otherwise.
|
||||
*/
|
||||
public boolean hasRaceId (int... raceIds) {
|
||||
for (int id : raceIds) {
|
||||
if (id == boat.getId())
|
||||
@@ -257,10 +263,22 @@ public class BoatGroup extends RaceObject{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all raceIds associated with this group. For BoatGroups the ID's are for the boat.
|
||||
*
|
||||
* @return An array containing all ID's associated with this RaceObject.
|
||||
*/
|
||||
public int[] getRaceIds () {
|
||||
return new int[] {boat.getId()};
|
||||
}
|
||||
|
||||
/**
|
||||
* Due to javaFX limitations annotations associated with a boat that you want to appear below all boats in the
|
||||
* Z-axis need to be pulled out of the BoatGroup and added to the parent group of the BoatGroups. This function
|
||||
* returns these annotations as a group.
|
||||
*
|
||||
* @return A group containing low priority annotations.
|
||||
*/
|
||||
public Group getLowPriorityAnnotations () {
|
||||
Group group = new Group();
|
||||
group.getChildren().addAll(wake, lineGroup);
|
||||
|
||||
@@ -18,8 +18,6 @@ public abstract class RaceObject extends Group {
|
||||
protected double pixelVelocityX;
|
||||
protected double pixelVelocityY;
|
||||
|
||||
static double max = 0;
|
||||
|
||||
public Point2D getPosition () {
|
||||
return new Point2D(super.getLayoutX(), getLayoutY());
|
||||
}
|
||||
@@ -28,10 +26,16 @@ public abstract class RaceObject extends Group {
|
||||
return expectedUpdateInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static void setExpectedUpdateInterval(double expectedUpdateInterval) {
|
||||
RaceObject.expectedUpdateInterval = expectedUpdateInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the rotational velocity required to reach the rotationalGoal from the currentRotation.
|
||||
*/
|
||||
protected void calculateRotationalVelocity () {
|
||||
if (Math.abs(rotationalGoal - currentRotation) > 180) {
|
||||
if (rotationalGoal - currentRotation >= 0) {
|
||||
@@ -47,20 +51,24 @@ public abstract class RaceObject extends Group {
|
||||
rotationalVelocity = 0;
|
||||
rotateTo(rotationalGoal);
|
||||
}
|
||||
// max = Math.max(max, Math.abs(rotationalVelocity));
|
||||
// System.out.println("max = " + max);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the destination of everything within the RaceObject that has an ID in the array raceIds. The destination is
|
||||
* set to the co-ordinates (x, y) with the given rotation.
|
||||
* @param x
|
||||
* @param y
|
||||
* @param rotation
|
||||
* @param raceIds
|
||||
* @param x X co-ordinate to move the graphics to.
|
||||
* @param y Y co-ordinate to move the graphics to.
|
||||
* @param rotation Rotation to move graphics to.
|
||||
* @param raceIds RaceID of the object to move.
|
||||
*/
|
||||
public abstract void setDestination (double x, double y, double rotation, int... raceIds);
|
||||
|
||||
/**
|
||||
* Sets the destination of everything within the RaceObject that has an ID in the array raceIds. The destination is
|
||||
* set to the co-ordinates (x, y).
|
||||
* @param x X co-ordinate to move the graphic to.
|
||||
* @param y Y co-ordinate to move the graphic to.
|
||||
* @param raceIds RaceID to the object to move.
|
||||
*/
|
||||
public abstract void setDestination (double x, double y, int... raceIds);
|
||||
|
||||
public abstract void updatePosition (long timeInterval);
|
||||
|
||||
@@ -21,8 +21,6 @@ class Wake extends Group {
|
||||
private double[] rotations = new double[numWakes];
|
||||
private int[] velocityIndices = new int[numWakes];
|
||||
private double sum = 0;
|
||||
static double max = 0;
|
||||
static double min = Double.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* Create a wake at the given location.
|
||||
@@ -54,17 +52,12 @@ class Wake extends Group {
|
||||
rotationalVelocity = 0;
|
||||
}
|
||||
sum -= Math.abs(velocities[(velocityIndices[0] + 10) % 13]);
|
||||
// sum -= Math.abs(velocities[velocityIndices[0]]);
|
||||
sum += Math.abs(rotationalVelocity);
|
||||
System.out.println("sum = " + sum);
|
||||
if (sum < 0.9)
|
||||
rotate (rotationGoal); //In relatively straight segments the wake snaps to match the boats current position.
|
||||
//This stops the wake from eventually becoming out of sync with the boat.
|
||||
//This stops the wake from eventually becoming out of sync with the boat.
|
||||
|
||||
max = Math.max(max, sum);
|
||||
min = Math.min(max, sum);
|
||||
System.out.println("max = " + max);
|
||||
System.out.println("min = " + min);
|
||||
//Update the index of the array of recent velocities that each wake uses. Each wake is 3 velocities behind the
|
||||
//next smallest wake.
|
||||
velocityIndices[0] = (13 + (velocityIndices[0] - 1) % 13) % 13;
|
||||
|
||||
Reference in New Issue
Block a user