mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added/improved documentation
#chore
This commit is contained in:
@@ -8,30 +8,29 @@ import javafx.scene.shape.StrokeLineCap;
|
||||
import javafx.scene.transform.Rotate;
|
||||
|
||||
/**
|
||||
* By default wake is a group containing 5 arcs. Each arc starts from the same point. Each arc is larger and more
|
||||
* transparent than the last. On calling updatePositions() arcs rotate at velocities given by setRotationalVelocity().
|
||||
* The larger and more transparent an arc is the longer the delay before it rotates at the latest velocity. It is
|
||||
* assumed that rotationalVelocities() are set regularly as wakes do not stop rotating and an array of velocities needs
|
||||
* to be populated for the class to work as expected.
|
||||
* A group containing objects used to represent wakes onscreen. Contains functionality for their animation.
|
||||
*/
|
||||
class Wake extends Group {
|
||||
|
||||
//Wake Settings. Should probably be hard coded in when the final values are decided upon.
|
||||
//Wake Settings.
|
||||
//Changes the relationship between separation of wakes and velocity. Only logarithmic is guaranteed to work always since it's my favourite :/.
|
||||
private enum functionType {LINEAR, LOGARITHMIC, POWER, ROOT, POWOUT_LOGIN}
|
||||
private functionType wakeFunction = functionType.LOGARITHMIC;
|
||||
//Change the wake style. Currently can be ArcType.OPEN or ArcType.ROUND
|
||||
private ArcType arcType = ArcType.OPEN;
|
||||
//The number of wakes
|
||||
private int numWakes = 10;
|
||||
private double offSet = 0;
|
||||
private final double MAX_DIFF = 75.0;
|
||||
//The total possible difference between the first wake and the last. Increasing/Decreasing this will make wakes fan out more/less.
|
||||
private final double MAX_DIFF = 75;
|
||||
//Increasing/decreasing this will alter the speed that wakes converge when the heading stop changing. Anything over about 1500 may cause oscillation.
|
||||
private final int UNIFICATION_SPEED = 500;
|
||||
//The power used for the power function. Changing this will probably break stuff in a cool way.
|
||||
private final int POWER = 2;
|
||||
|
||||
private Arc[] arcs = new Arc[numWakes];
|
||||
private double[] rotationalVelocities = new double[numWakes];
|
||||
private double[] rotations = new double[numWakes];
|
||||
private double baseRad;
|
||||
private boolean spawnNewWake = false;
|
||||
private int count = 10;
|
||||
|
||||
/**
|
||||
* Create a wake at the given location.
|
||||
@@ -65,8 +64,8 @@ class Wake extends Group {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rotationalVelocity of each arc. Each arc is 3 velocities behind the next smallest arc. The smallest uses
|
||||
* the latest given velocity.
|
||||
* Sets the rotationalVelocity of each arc.
|
||||
*
|
||||
* @param rotationalVelocity The rotationalVelocity the wake should move at.
|
||||
* @param velocity The real world velocity of the boat in m/s.
|
||||
*/
|
||||
@@ -89,11 +88,11 @@ class Wake extends Group {
|
||||
|
||||
if (wakeFunction == functionType.LOGARITHMIC) {
|
||||
if (rotationalVelocities[i-1] < 0.01 && rotationalVelocities[i-1] > -0.01) {
|
||||
rotationalVelocities[i] = (MAX_DIFF / numWakes) / UNIFICATION_SPEED * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes) * 1.5;
|
||||
if (difference < 0)
|
||||
{
|
||||
rotationalVelocities[i] = -rotationalVelocities[i];
|
||||
}
|
||||
rotationalVelocities[i] = difference / UNIFICATION_SPEED * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes) * 1.5;
|
||||
// if (difference < 0)
|
||||
// {
|
||||
// rotationalVelocities[i] = -rotationalVelocities[i];
|
||||
// }
|
||||
} else {
|
||||
rotationalVelocities[i] = rotationalVelocities[i-1] * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes);
|
||||
}
|
||||
@@ -148,7 +147,7 @@ class Wake extends Group {
|
||||
// } else {
|
||||
// offSet += baseRad / 5;
|
||||
// }
|
||||
double rad = baseRad + velocity + offSet;
|
||||
double rad = baseRad + velocity;
|
||||
for (Arc arc :arcs) {
|
||||
arc.setRadiusX(rad);
|
||||
arc.setRadiusY(rad);
|
||||
|
||||
@@ -126,42 +126,42 @@ public class MarkGroup extends RaceObject {
|
||||
}
|
||||
|
||||
public void updatePosition (long timeInterval) {
|
||||
// Circle markCircle = (Circle) super.getChildren().get(0);
|
||||
//
|
||||
// if (nodePixelVelocitiesX[0] > 0 && markCircle.getCenterX() > nodeDestinations[0].getX() ||
|
||||
// nodePixelVelocitiesX[0] < 0 && markCircle.getCenterX() < nodeDestinations[0].getY())
|
||||
// nodePixelVelocitiesX[0] = 0;
|
||||
// else if (nodePixelVelocitiesX[0] != 0)
|
||||
// markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[0] * timeInterval);
|
||||
//
|
||||
// if (nodePixelVelocitiesY[0] > 0 && markCircle.getCenterY() > nodeDestinations[0].getY() ||
|
||||
// nodePixelVelocitiesY[0] < 0 && markCircle.getCenterY() < nodeDestinations[0].getY())
|
||||
// nodePixelVelocitiesY[0] = 0;
|
||||
// else if (nodePixelVelocitiesY[0] != 0)
|
||||
// markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[0] * timeInterval);
|
||||
//
|
||||
// if (mainMark.getMarkType() != MarkType.SINGLE_MARK) {
|
||||
//
|
||||
// Line line = (Line) super.getChildren().get(2);
|
||||
// line.setStartX(markCircle.getCenterX());
|
||||
// line.setStartY(markCircle.getCenterY());
|
||||
//
|
||||
// markCircle = (Circle) super.getChildren().get(1);
|
||||
//
|
||||
// if (nodePixelVelocitiesX[1] > 0 && markCircle.getCenterX() >= nodeDestinations[1].getX() ||
|
||||
// nodePixelVelocitiesX[1] < 0 && markCircle.getCenterX() <= nodeDestinations[1].getX())
|
||||
// nodePixelVelocitiesX[1] = 0;
|
||||
// else if (nodePixelVelocitiesX[1] != 0)
|
||||
// markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[1] * timeInterval);
|
||||
//
|
||||
// if (nodePixelVelocitiesY[1] > 0 && markCircle.getCenterY() > nodeDestinations[1].getY() ||
|
||||
// nodePixelVelocitiesY[1] < 0 && markCircle.getCenterY() < nodeDestinations[1].getY())
|
||||
// nodePixelVelocitiesY[1] = 0;
|
||||
// else if (nodePixelVelocitiesY[1] != 0)
|
||||
// markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[1] * timeInterval);
|
||||
// line.setEndX(markCircle.getCenterX());
|
||||
// line.setEndY(markCircle.getCenterY());
|
||||
// }
|
||||
Circle markCircle = (Circle) super.getChildren().get(0);
|
||||
|
||||
if (nodePixelVelocitiesX[0] > 0 && markCircle.getCenterX() > nodeDestinations[0].getX() ||
|
||||
nodePixelVelocitiesX[0] < 0 && markCircle.getCenterX() < nodeDestinations[0].getY())
|
||||
nodePixelVelocitiesX[0] = 0;
|
||||
else if (nodePixelVelocitiesX[0] != 0)
|
||||
markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[0] * timeInterval);
|
||||
|
||||
if (nodePixelVelocitiesY[0] > 0 && markCircle.getCenterY() > nodeDestinations[0].getY() ||
|
||||
nodePixelVelocitiesY[0] < 0 && markCircle.getCenterY() < nodeDestinations[0].getY())
|
||||
nodePixelVelocitiesY[0] = 0;
|
||||
else if (nodePixelVelocitiesY[0] != 0)
|
||||
markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[0] * timeInterval);
|
||||
|
||||
if (mainMark.getMarkType() != MarkType.SINGLE_MARK) {
|
||||
|
||||
Line line = (Line) super.getChildren().get(2);
|
||||
line.setStartX(markCircle.getCenterX());
|
||||
line.setStartY(markCircle.getCenterY());
|
||||
|
||||
markCircle = (Circle) super.getChildren().get(1);
|
||||
|
||||
if (nodePixelVelocitiesX[1] > 0 && markCircle.getCenterX() >= nodeDestinations[1].getX() ||
|
||||
nodePixelVelocitiesX[1] < 0 && markCircle.getCenterX() <= nodeDestinations[1].getX())
|
||||
nodePixelVelocitiesX[1] = 0;
|
||||
else if (nodePixelVelocitiesX[1] != 0)
|
||||
markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[1] * timeInterval);
|
||||
|
||||
if (nodePixelVelocitiesY[1] > 0 && markCircle.getCenterY() > nodeDestinations[1].getY() ||
|
||||
nodePixelVelocitiesY[1] < 0 && markCircle.getCenterY() < nodeDestinations[1].getY())
|
||||
nodePixelVelocitiesY[1] = 0;
|
||||
else if (nodePixelVelocitiesY[1] != 0)
|
||||
markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[1] * timeInterval);
|
||||
line.setEndX(markCircle.getCenterX());
|
||||
line.setEndY(markCircle.getCenterY());
|
||||
}
|
||||
}
|
||||
|
||||
public void moveGroupBy (double x, double y, double rotation) {
|
||||
|
||||
Reference in New Issue
Block a user