mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Started trying to get the zoomed in gave view to follow the boat.
Can easily make the boat stay put at the origin. can make it perfectly center, also weary of the weird jittery effect that is present when tracking. Tracking is active when the zoom scale is greater than 1. #story[1121]
This commit is contained in:
@@ -88,15 +88,15 @@ public class GameView extends Pane {
|
||||
double scaleFactor = 1;
|
||||
|
||||
public void zoomOut() {
|
||||
scaleFactor = 0.95;
|
||||
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||
scaleFactor = 0.05;
|
||||
this.setScaleX(this.getScaleX() - scaleFactor);
|
||||
this.setScaleY(this.getScaleY() - scaleFactor);
|
||||
}
|
||||
|
||||
public void zoomIn() {
|
||||
scaleFactor = 1.05;
|
||||
this.setScaleX(this.getScaleX() * scaleFactor);
|
||||
this.setScaleY(this.getScaleY() * scaleFactor);
|
||||
scaleFactor = 0.05;
|
||||
this.setScaleX(this.getScaleX() + scaleFactor);
|
||||
this.setScaleY(this.getScaleY() + scaleFactor);
|
||||
}
|
||||
|
||||
private enum ScaleDirection {
|
||||
@@ -104,6 +104,25 @@ public class GameView extends Pane {
|
||||
VERTICAL
|
||||
}
|
||||
|
||||
public void trackBoat() {
|
||||
if (this.getScaleX() > 1) {
|
||||
double x = boatObjects.get(playerYacht).getBoatLayoutX();
|
||||
double y = boatObjects.get(playerYacht).getBoatLayoutY();
|
||||
// System.out.println("x = " + x);
|
||||
// System.out.println("y = " + y);
|
||||
// this.setRotate(-playerYacht.getHeading());
|
||||
Point2D displacementX = findScaledXY(maxLonPoint);
|
||||
Point2D displacementY = findScaledXY(maxLatPoint);
|
||||
this.setLayoutX(-x + 250 + canvasWidth/2);
|
||||
this.setLayoutY(-y + canvasHeight/2);
|
||||
} else {
|
||||
this.setLayoutX(0);
|
||||
this.setLayoutY(0);
|
||||
}
|
||||
System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutX());
|
||||
System.out.println("boatObjects = " + boatObjects.get(playerYacht).getBoatLayoutY());
|
||||
}
|
||||
|
||||
public GameView () {
|
||||
gameObjects = this.getChildren();
|
||||
// create image view for map, bind panel size to image
|
||||
|
||||
Reference in New Issue
Block a user