Wakes still broken. Implemented dashed lines that track the progress of individual boats.

#implement #story[483]
This commit is contained in:
Calum
2017-04-27 13:57:19 +12:00
parent 65c0e6f77d
commit 67a702ffcd
7 changed files with 105 additions and 63 deletions
+15 -10
View File
@@ -3,6 +3,7 @@ package seng302.models;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.transform.Rotate;
/**
* Created by CJIRWIN on 27/04/2017.
@@ -10,36 +11,40 @@ import javafx.scene.shape.ArcType;
class Wake extends Arc {
private static int VELOCITY_SCALE_FACTOR = 3;
private static int MAX_LIFESPAN = 420;
private static int MAX_LIFESPAN = 210;
private static double LIFESPAN_PER_FRAME = 1.0 / MAX_LIFESPAN;
//private static double LENGTH_PER_FRAME = 120 / MAX_LIFESPAN;
private static double LENGTH_PER_FRAME = 0.08;
private static double LENGTH_PER_FRAME = 0.25;
private double velocityX;
private double velocityY;
private double opacity;
private int lifespan = MAX_LIFESPAN;
Wake (double startingX, double startingY, double velocityX, double velocityY) {
super(0, 0, 20, 30, 180, 0);
Wake (double startingX, double startingY, double velocityX, double velocityY, double rotation) {
super(startingX + 20, startingY + 30, 20, 30, 180, 0);
//super.setFill(Color.BLUE);
super.setStroke(Color.BLUE);
super.setStroke(Color.DEEPSKYBLUE);
super.setType(ArcType.OPEN);
super.setFill(new Color(0, 0, 0 ,0));
super.setStrokeWidth(2.0);
this.velocityX = -velocityX / 2;
this.velocityY = -velocityY / 2;
super.getTransforms().add(new Rotate(rotation - 270, startingX + 20, startingY + 20));
// this.velocityX = -velocityX;
// this.velocityY = -velocityY;
this.velocityX = 0;
this.velocityY = 0;
}
boolean updatePosition (double timeInterval) {
lifespan--;
//super.setOpacity(LIFESPAN_PER_FRAME * lifespan * super.getOpacity());
opacity = LIFESPAN_PER_FRAME * lifespan * opacity;
super.setFill(new Color(0.0f, 0.0f, 1.0f, opacity));
//opacity = LIFESPAN_PER_FRAME * lifespan * opacity;
//super.setFill(new Color(0.0f, 0.0f, 1.0f, opacity));
super.setLayoutX(super.getLayoutX() + velocityX * timeInterval);
super.setLayoutY(super.getLayoutY() + velocityY * timeInterval);
super.setStartAngle(super.getStartAngle() - LENGTH_PER_FRAME);
super.setLength(super.getLength() + LENGTH_PER_FRAME * 2);
return lifespan == 0;
return lifespan < 0;
}
}