mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Tested several methods of creating 3D assets. Added a 3D file importer to library of project and replaced some assets with temporary 32 ones to test creating 32 objects.
#implement
This commit is contained in:
@@ -5,6 +5,7 @@ import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.SceneAntialiasing;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
@@ -14,7 +15,6 @@ import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seng302.model.PolarTable;
|
||||
|
||||
public class App extends Application {
|
||||
|
||||
@@ -69,7 +69,7 @@ public class App extends Application {
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
Parent root = FXMLLoader.load(getClass().getResource("/views/StartScreenView.fxml"));
|
||||
primaryStage.setTitle("Party Parrots at Sea");
|
||||
Scene scene = new Scene(root, 1530, 960);
|
||||
Scene scene = new Scene(root, 1530, 960, false, SceneAntialiasing.BALANCED);
|
||||
scene.getStylesheets().add(getClass().getResource("/css/master.css").toString());
|
||||
primaryStage.setScene(scene);
|
||||
// primaryStage.setMaxWidth(1530);
|
||||
|
||||
@@ -20,8 +20,6 @@ import seng302.gameServer.messages.MarkRoundingMessage;
|
||||
import seng302.gameServer.messages.MarkType;
|
||||
import seng302.gameServer.messages.Message;
|
||||
import seng302.gameServer.messages.RoundingBoatStatus;
|
||||
import seng302.gameServer.messages.XMLMessage;
|
||||
import seng302.gameServer.messages.XMLMessageSubType;
|
||||
import seng302.gameServer.messages.YachtEventCodeMessage;
|
||||
import seng302.model.GeoPoint;
|
||||
import seng302.model.Limit;
|
||||
@@ -31,11 +29,9 @@ import seng302.model.ServerYacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.mark.MarkOrder;
|
||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.model.token.TokenType;
|
||||
import seng302.utilities.GeoUtility;
|
||||
import seng302.utilities.XMLGenerator;
|
||||
import seng302.utilities.XMLParser;
|
||||
|
||||
/**
|
||||
@@ -426,7 +422,7 @@ public class GameState implements Runnable {
|
||||
private void updateVelocity(ServerYacht yacht) {
|
||||
Double trueWindAngle = Math.abs(windDirection - yacht.getHeading());
|
||||
Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle);
|
||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots);
|
||||
Double maxBoatSpeed = GeoUtility.knotsToMMS(boatSpeedInKnots) * 4;
|
||||
if (yacht.getPowerUp() != null) {
|
||||
if (yacht.getPowerUp().equals(TokenType.BOOST)) {
|
||||
maxBoatSpeed *= 2;
|
||||
@@ -732,7 +728,8 @@ public class GameState implements Runnable {
|
||||
// TODO: 13/8/17 figure out the rounding side, rounded mark source ID and boat status.
|
||||
Message markRoundingMessage = new MarkRoundingMessage(0, 0,
|
||||
sourceID, RoundingBoatStatus.RACING, roundingMark.getRoundingSide(), markType,
|
||||
currentMarkSeqID + 1);
|
||||
currentMark.getId());
|
||||
// currentMarkSeqID + 1);
|
||||
|
||||
notifyMessageListeners(markRoundingMessage);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import seng302.model.stream.parser.RaceStatusData;
|
||||
import seng302.model.stream.parser.YachtEventData;
|
||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
import seng302.model.stream.xml.parser.RegattaXMLData;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.utilities.StreamParser;
|
||||
import seng302.utilities.XMLParser;
|
||||
import seng302.visualiser.controllers.FinishScreenViewController;
|
||||
@@ -155,11 +154,6 @@ public class GameClient {
|
||||
}
|
||||
|
||||
private void loadStartScreen() {
|
||||
// socketThread.setSocketToClose();
|
||||
// if (server != null) {
|
||||
// server.terminate();
|
||||
// server = null;
|
||||
// }
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(
|
||||
getClass().getResource("/views/StartScreenView.fxml"));
|
||||
try {
|
||||
@@ -258,12 +252,14 @@ public class GameClient {
|
||||
break;
|
||||
|
||||
case RACE_XML:
|
||||
courseData = XMLParser.parseRace(
|
||||
RaceXMLData raceXMLData = XMLParser.parseRace(
|
||||
StreamParser.extractXmlMessage(packet)
|
||||
);
|
||||
|
||||
if (courseData == null) { //workaround for object comparisons. Avoid recreating
|
||||
courseData = raceXMLData;
|
||||
}
|
||||
if (raceView != null) {
|
||||
raceView.updateRaceData(courseData);
|
||||
raceView.updateRaceData(raceXMLData);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import javafx.animation.Timeline;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.image.ImageView;
|
||||
@@ -22,27 +23,22 @@ import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.shape.Cylinder;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.transform.Rotate;
|
||||
import javafx.util.Duration;
|
||||
import seng302.gameServer.GameState;
|
||||
import seng302.gameServer.messages.XMLMessage;
|
||||
import seng302.gameServer.messages.XMLMessageSubType;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.gameServer.messages.RoundingSide;
|
||||
import seng302.model.ClientYacht;
|
||||
import seng302.model.Colors;
|
||||
import seng302.model.GeoPoint;
|
||||
import seng302.model.Limit;
|
||||
import seng302.model.ServerYacht;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Corner;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.stream.xml.generator.RaceXMLTemplate;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.utilities.GeoUtility;
|
||||
import seng302.utilities.XMLGenerator;
|
||||
import seng302.visualiser.fxObjects.AnnotationBox;
|
||||
import seng302.visualiser.fxObjects.BoatObject;
|
||||
import seng302.visualiser.fxObjects.CourseBoundary;
|
||||
@@ -91,6 +87,7 @@ public class GameView extends Pane {
|
||||
private Group markers = new Group();
|
||||
private Group tokens = new Group();
|
||||
private List<CompoundMark> course = new ArrayList<>();
|
||||
private List<Cylinder> mapTokens;
|
||||
|
||||
private ImageView mapImage = new ImageView();
|
||||
|
||||
@@ -190,6 +187,9 @@ public class GameView extends Pane {
|
||||
}
|
||||
}
|
||||
boatObjects.forEach((boat, boatObject) -> boatObject.updateLocation());
|
||||
for (Cylinder c : mapTokens) {
|
||||
c.getTransforms().add(new Rotate(1, new Point3D(45, 45, 45)));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -315,18 +315,16 @@ public class GameView extends Pane {
|
||||
for (int i=1; i < sequence.size()-1; i++) { //General case.
|
||||
double averageLat = 0;
|
||||
double averageLng = 0;
|
||||
int numMarks = 0;
|
||||
int numMarks = course.get(i-1).getMarks().size();
|
||||
for (Mark mark : course.get(i-1).getMarks()) {
|
||||
numMarks += 1;
|
||||
averageLat += mark.getLat();
|
||||
averageLng += mark.getLng();
|
||||
}
|
||||
GeoPoint lastMarkAv = new GeoPoint(averageLat / numMarks, averageLng / numMarks);
|
||||
numMarks = 0;
|
||||
numMarks = course.get(i+1).getMarks().size();
|
||||
averageLat = 0;
|
||||
averageLng = 0;
|
||||
for (Mark mark : course.get(i+1).getMarks()) {
|
||||
numMarks += 1;
|
||||
averageLat += mark.getLat();
|
||||
averageLng += mark.getLng();
|
||||
}
|
||||
@@ -451,15 +449,26 @@ public class GameView extends Pane {
|
||||
*/
|
||||
public void updateTokens(List<Token> newTokens) {
|
||||
|
||||
List<Marker> mapTokens = new ArrayList<>();
|
||||
|
||||
// List<Marker> mapTokens = new ArrayList<>();
|
||||
//
|
||||
// for (Token token : newTokens) {
|
||||
// Point2D location = findScaledXY(token.getLat(), token.getLng());
|
||||
// Marker thisMarker = new Marker(Color.YELLOW);
|
||||
// thisMarker.setLayoutX(location.getX());
|
||||
// thisMarker.setLayoutY(location.getY());
|
||||
// mapTokens.add(thisMarker);
|
||||
// }
|
||||
mapTokens = new ArrayList<>();
|
||||
for (Token token : newTokens) {
|
||||
Point2D location = findScaledXY(token.getLat(), token.getLng());
|
||||
Marker thisMarker = new Marker(Color.YELLOW);
|
||||
thisMarker.setLayoutX(location.getX());
|
||||
thisMarker.setLayoutY(location.getY());
|
||||
mapTokens.add(thisMarker);
|
||||
Cylinder tokenObject = new Cylinder(10, 10);
|
||||
tokenObject.getTransforms().add(new Rotate(45, new Point3D(45, 45, 45)));
|
||||
tokenObject.setLayoutX(location.getX());
|
||||
tokenObject.setLayoutY(location.getY());
|
||||
tokenObject.setMaterial(new PhongMaterial(Color.YELLOW));
|
||||
mapTokens.add(tokenObject);
|
||||
}
|
||||
|
||||
Platform.runLater(() -> {
|
||||
tokens.getChildren().clear();
|
||||
tokens.getChildren().addAll(mapTokens);
|
||||
@@ -518,7 +527,7 @@ public class GameView extends Pane {
|
||||
BoatObject newBoat;
|
||||
final List<Group> wakes = new ArrayList<>();
|
||||
for (ClientYacht clientYacht : yachts) {
|
||||
Paint colour = clientYacht.getColour();
|
||||
Color colour = clientYacht.getColour();
|
||||
newBoat = new BoatObject();
|
||||
newBoat.addSelectedBoatListener(this::setSelectedBoat);
|
||||
newBoat.setFill(colour);
|
||||
@@ -528,7 +537,7 @@ public class GameView extends Pane {
|
||||
wakes.add(newBoat.getWake());
|
||||
boatObjectGroup.getChildren().add(newBoat);
|
||||
trails.getChildren().add(newBoat.getTrail());
|
||||
// TODO: 1/08/17 Make this less vile to look at.
|
||||
|
||||
clientYacht.addLocationListener((boat, lat, lon, heading, sailIn, velocity) -> {
|
||||
BoatObject bo = boatObjects.get(boat);
|
||||
Point2D p2d = findScaledXY(lat, lon);
|
||||
@@ -815,8 +824,10 @@ public class GameView extends Pane {
|
||||
|
||||
private void updateMarkArrows (ClientYacht yacht, CompoundMark compoundMark, int legNumber) {
|
||||
//Only show arrows for this and next leg.
|
||||
// System.out.println(markerObjects);
|
||||
if (compoundMark != null) {
|
||||
for (Mark mark : compoundMark.getMarks()) {
|
||||
// System.out.println("markerObjects.get(mark) = " + markerObjects.get(mark));
|
||||
markerObjects.get(mark).showNextExitArrow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import seng302.model.RaceState;
|
||||
import seng302.model.mark.CompoundMark;
|
||||
import seng302.model.mark.Mark;
|
||||
import seng302.model.stream.xml.parser.RaceXMLData;
|
||||
import seng302.model.token.Token;
|
||||
import seng302.visualiser.GameView;
|
||||
import seng302.visualiser.controllers.annotations.Annotation;
|
||||
import seng302.visualiser.controllers.annotations.ImportantAnnotationController;
|
||||
@@ -621,7 +620,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
}
|
||||
|
||||
public void updateRaceData (RaceXMLData raceData) {
|
||||
this.courseData = raceData;
|
||||
gameView.updateBorder(raceData.getCourseLimit());
|
||||
gameView.updateTokens(raceData.getTokens());
|
||||
}
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
package seng302.visualiser.fxObjects;
|
||||
|
||||
import com.interactivemesh.jfx.importer.stl.StlMeshImporter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javafx.application.Platform;
|
||||
import javafx.geometry.Point2D;
|
||||
import javafx.geometry.Point3D;
|
||||
import javafx.scene.Group;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.PointLight;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.Paint;
|
||||
import javafx.scene.paint.PhongMaterial;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.scene.shape.MeshView;
|
||||
import javafx.scene.shape.Polygon;
|
||||
import javafx.scene.shape.Polyline;
|
||||
import javafx.scene.shape.StrokeLineCap;
|
||||
import javafx.scene.shape.Shape3D;
|
||||
import javafx.scene.transform.Rotate;
|
||||
|
||||
/**
|
||||
@@ -24,6 +28,17 @@ import javafx.scene.transform.Rotate;
|
||||
*/
|
||||
public class BoatObject extends Group {
|
||||
|
||||
|
||||
private static final double MODEL_SCALE_FACTOR = 400;
|
||||
private static final double MODEL_X_OFFSET = 0; // standard
|
||||
private static final double MODEL_Y_OFFSET = 0; // standard
|
||||
|
||||
private static final int VIEWPORT_SIZE = 800;
|
||||
|
||||
private static final Color lightColor = Color.rgb(244, 255, 250);
|
||||
private static final Color jewelColor = Color.rgb(0, 190, 222);
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SelectedBoatListener {
|
||||
|
||||
@@ -31,8 +46,8 @@ public class BoatObject extends Group {
|
||||
}
|
||||
|
||||
//Constants for drawing
|
||||
private static final double BOAT_HEIGHT = 15d;
|
||||
private static final double BOAT_WIDTH = 10d;
|
||||
private static final float BOAT_HEIGHT = 15f;
|
||||
private static final float BOAT_WIDTH = 10f;
|
||||
|
||||
private double xVelocity;
|
||||
private double yVelocity;
|
||||
@@ -40,14 +55,15 @@ public class BoatObject extends Group {
|
||||
private double sailState;
|
||||
//Graphical objects
|
||||
private Polyline trail = new Polyline();
|
||||
private Polygon boatPoly;
|
||||
// private Polygon boatPoly;
|
||||
private Shape3D boatPoly;
|
||||
private Polygon sail;
|
||||
private Wake wake;
|
||||
private Line leftLayLine;
|
||||
private Line rightLayline;
|
||||
private double distanceTravelled, lastRotation;
|
||||
private Point2D lastPoint;
|
||||
private Paint colour = Color.BLACK;
|
||||
private Color colour = Color.BLACK;
|
||||
private Boolean isSelected = false, destinationSet; //All boats are initialised as selected
|
||||
private boolean isPlayer = false;
|
||||
|
||||
@@ -80,17 +96,20 @@ public class BoatObject extends Group {
|
||||
* polygon.
|
||||
*/
|
||||
private void initChildren(double... points) {
|
||||
boatPoly = new Polygon(points);
|
||||
boatPoly.setFill(colour);
|
||||
boatPoly.setFill(this.colour);
|
||||
boatPoly = makeBoatPolygon();
|
||||
// boatPoly.setFill(colour);
|
||||
// boatPoly.setFill(this.colour);
|
||||
// boatPoly.setMaterial(new PhongMaterial(this.colour));
|
||||
boatPoly.setOnMouseEntered(event -> {
|
||||
boatPoly.setFill(Color.FLORALWHITE);
|
||||
boatPoly.setStroke(Color.RED);
|
||||
// boatPoly.setFill(Color.FLORALWHITE);
|
||||
// boatPoly.setStroke(Color.RED);
|
||||
// boatPoly.setMaterial(new PhongMaterial(Color.FLORALWHITE));
|
||||
});
|
||||
boatPoly.setOnMouseExited(event -> {
|
||||
boatPoly.setFill(colour);
|
||||
boatPoly.setFill(this.colour);
|
||||
boatPoly.setStroke(Color.BLACK);
|
||||
// boatPoly.setMaterial(new PhongMaterial(this.colour));
|
||||
// boatPoly.setFill(colour);
|
||||
// boatPoly.setFill(this.colour);
|
||||
// boatPoly.setStroke(Color.BLACK);
|
||||
});
|
||||
boatPoly.setOnMouseClicked(event -> setIsSelected(!isSelected));
|
||||
boatPoly.setCache(true);
|
||||
@@ -117,12 +136,91 @@ public class BoatObject extends Group {
|
||||
super.getChildren().addAll(boatPoly, sail);
|
||||
}
|
||||
|
||||
public void setFill (Paint value) {
|
||||
public void setFill (Color value) {
|
||||
|
||||
|
||||
PointLight pointLight = new PointLight();
|
||||
// pointLight.setTranslateX(VIEWPORT_SIZE*3/4);
|
||||
// pointLight.setTranslateY(VIEWPORT_SIZE/2);
|
||||
// pointLight.setTranslateZ(VIEWPORT_SIZE/2);
|
||||
|
||||
// PointLight pointLight2 = new PointLight(lightColor);
|
||||
// pointLight2.setTranslateX(VIEWPORT_SIZE*1/4);
|
||||
// pointLight2.setTranslateY(VIEWPORT_SIZE*3/4);
|
||||
// pointLight2.setTranslateZ(VIEWPORT_SIZE*3/4);
|
||||
// PointLight pointLight3 = new PointLight(lightColor);
|
||||
// pointLight3.setTranslateX(VIEWPORT_SIZE*5/8);
|
||||
// pointLight3.setTranslateY(VIEWPORT_SIZE/2);
|
||||
// pointLight3.setTranslateZ(0);
|
||||
//
|
||||
// Color ambientColor = Color.rgb(80, 80, 80, 0);
|
||||
// AmbientLight ambient = new AmbientLight(ambientColor);
|
||||
|
||||
this.getChildren().add(pointLight);
|
||||
// this.getChildren().add(pointLight2);
|
||||
// this.getChildren().add(pointLight3);
|
||||
// this.getChildren().add(ambient);
|
||||
|
||||
this.colour = value;
|
||||
boatPoly.setFill(colour);
|
||||
PhongMaterial pm = new PhongMaterial(this.colour);
|
||||
// pm.setSpecularPower(16);
|
||||
// pm.setSpecularColor(lightColor);
|
||||
boatPoly.setMaterial(pm);
|
||||
trail.setStroke(colour);
|
||||
}
|
||||
|
||||
public Shape3D makeBoatPolygon () {
|
||||
StlMeshImporter importer = new StlMeshImporter();
|
||||
// System.out.println(BoatObject.class.getResource("simpleboat.stl").toString());
|
||||
System.out.println(BoatObject.class.getResource("/views/StartScreenView.fxml").toString());
|
||||
importer.read(getClass().getResource("/simpleboat.stl").toString());
|
||||
return new MeshView(importer.getImport());
|
||||
// MeshView boat = new MeshView();
|
||||
// TriangleMesh boatMesh = new TriangleMesh();
|
||||
//// -BOAT_WIDTH / 2, BOAT_HEIGHT / 2,
|
||||
//// 0.0, -BOAT_HEIGHT / 2,
|
||||
//// BOAT_WIDTH / 2, BOAT_HEIGHT / 2
|
||||
// boatMesh.getPoints().addAll(
|
||||
// -BOAT_WIDTH / 2, BOAT_HEIGHT / 2, 0,
|
||||
// 0, -BOAT_HEIGHT / 2,0,
|
||||
// BOAT_WIDTH / 2, BOAT_HEIGHT / 2, 0
|
||||
// );
|
||||
// boatMesh.getTexCoords().addAll(0.5f,0,0,1,1,1);
|
||||
// boatMesh.getFaces().addAll(
|
||||
// 0,0,1,1,2,2//,
|
||||
//// 1,1,2,2,3,3,
|
||||
//// 0,0,2,2,3,3,
|
||||
//// 1,1,0,0,3,3
|
||||
// );
|
||||
// boat.setMesh(boatMesh);
|
||||
//// boat.setDrawMode(DrawMode.LINE);
|
||||
// return boat;
|
||||
//// Box b = new Box();
|
||||
//// TriangleMesh planeMesh = new TriangleMesh();
|
||||
//// float[] points = {
|
||||
//// -10, 10, 5,
|
||||
//// -10, -10, 10,
|
||||
//// 10, 10, 15,
|
||||
//// 10, 10, 20
|
||||
//// };
|
||||
//// float[] texCoords = {
|
||||
//// 0, 0,
|
||||
//// 0, 1,
|
||||
//// 1, 0,
|
||||
//// 1, 1
|
||||
//// };
|
||||
//// int[] faces = {
|
||||
//// 0, 0, 1, 1, 2, 2,
|
||||
//// 2, 2, 3, 3, 1, 1
|
||||
//// };
|
||||
//// planeMesh.getPoints().addAll(points);
|
||||
//// planeMesh.getTexCoords().addAll(texCoords);
|
||||
//// planeMesh.getFaces().addAll(faces);
|
||||
//// MeshView meshView = new MeshView(planeMesh);
|
||||
// meshView.setMaterial(new PhongMaterial(Color.BLACK));
|
||||
// return meshView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the boat and its children annotations to coordinates specified
|
||||
* @param x The X coordinate to move the boat to
|
||||
@@ -181,7 +279,7 @@ public class BoatObject extends Group {
|
||||
|
||||
|
||||
private void rotateTo(double heading, boolean sailsIn, double windDir) {
|
||||
boatPoly.getTransforms().setAll(new Rotate(heading));
|
||||
// boatPoly.getTransforms().add(new Rotate(heading, new Point3D(0,0,1)));
|
||||
if (sailsIn) {
|
||||
Double sailWindOffset = 30.0;
|
||||
Double upwindAngleLimit = 15.0;
|
||||
@@ -220,8 +318,8 @@ public class BoatObject extends Group {
|
||||
double period = 10;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
points[i * 2] = amplitude * Math.sin(((Math.PI * i) / period + sailState));
|
||||
points[i * 2 + 1] = (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
|
||||
points[199 - (i * 2)] = (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
|
||||
points[i * 2 + 1] = (double) (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
|
||||
points[199 - (i * 2)] = (double) (BOAT_HEIGHT * i) / BOAT_HEIGHT / 2;
|
||||
points[199 - (i * 2 + 1)] = amplitude * Math.sin(((Math.PI * i) / period + sailState));
|
||||
}
|
||||
if (sailState == - 2 * Math.PI) {
|
||||
@@ -235,6 +333,7 @@ public class BoatObject extends Group {
|
||||
}
|
||||
|
||||
public void updateLocation() {
|
||||
boatPoly.getTransforms().add(new Rotate(2, new Point3D(1,1,1)));
|
||||
// double dx = xVelocity / 60;
|
||||
// double dy = yVelocity / 60;
|
||||
//
|
||||
@@ -356,14 +455,14 @@ public class BoatObject extends Group {
|
||||
* Sets this boat to appear highlighted
|
||||
*/
|
||||
public void setAsPlayer() {
|
||||
boatPoly.getPoints().setAll(
|
||||
-BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
|
||||
0.0, -BOAT_HEIGHT / 1.75,
|
||||
BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
|
||||
);
|
||||
boatPoly.setStroke(Color.BLACK);
|
||||
boatPoly.setStrokeWidth(2);
|
||||
boatPoly.setStrokeLineCap(StrokeLineCap.ROUND);
|
||||
// boatPoly.getPoints().setAll(
|
||||
// -BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75,
|
||||
// 0.0, -BOAT_HEIGHT / 1.75,
|
||||
// BOAT_WIDTH / 1.75, BOAT_HEIGHT / 1.75
|
||||
// );
|
||||
// boatPoly.setStroke(Color.BLACK);
|
||||
// boatPoly.setStrokeWidth(2);
|
||||
// boatPoly.setStrokeLineCap(StrokeLineCap.ROUND);
|
||||
isPlayer = true;
|
||||
animateSail();
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user