Commit 1d794007 authored by Sergio Emanuel Rodriguez Rivera's avatar Sergio Emanuel Rodriguez Rivera
Browse files

fixed line

parent d8490ebd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -7,9 +7,8 @@
        <option value="$PROJECT_DIR$/pom.xml" />
      </list>
    </option>
    <option name="workspaceImportForciblyTurnedOn" value="true" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="22" project-jdk-type="JavaSDK">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="22" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
</project>
 No newline at end of file
+19 −14
Original line number Diff line number Diff line
@@ -8,12 +8,11 @@ import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.geometry.Bounds;
import javafx.geometry.Point3D;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.paint.PhongMaterial;
import javafx.scene.shape.Box;
@@ -224,22 +223,28 @@ public class GraphicsAndWindowsTest extends Application {
        //Lays out the children in Z order with the last member being front most
        //Effectively allows you to layer multiple elements
        //We are layering our 3D scene with a 2D label on top of it
        StackPane Layers = new StackPane();
        Layers.getChildren().addAll(subScene3D, fpsLabel, scoreLabel);
        StackPane.setAlignment(fpsLabel, Pos.BOTTOM_RIGHT); //Places FPS in bottom right
        StackPane.setAlignment(scoreLabel, Pos.TOP_LEFT); //Places FPS in bottom right
        // Use Pane instead of StackPane
        Pane layers = new Pane();  // This replaces StackPane for direct control
        layers.setPrefSize(1500, 800); // Set the preferred size to match the scene
        layers.getChildren().add(subScene3D);  // Add the 3D subscene
        layers.getChildren().addAll(fpsLabel, scoreLabel);  // Add labels

        fpsLabel.setLayoutX(1350); // Position the FPS label at the bottom-right corner
        fpsLabel.setLayoutY(780);
        scoreLabel.setLayoutX(20);  // Position the score label at the top-left corner
        scoreLabel.setLayoutY(20);

        Scene scene = new Scene(Layers, 1500, 800);

        Scene scene = new Scene(layers, 1500, 800);


        /*
        Mouse event for setting anchors
         */
        ourWindow.setOnMousePressed(mouseEvent -> {
        layers.setOnMousePressed(mouseEvent -> {
            anchorX = mouseEvent.getX();
            anchorY = mouseEvent.getY();
            //System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY);
            System.out.println("Mouse pressed at: " + anchorX + ", " + anchorY);

            slingLine.setStroke(Color.RED);
            slingLine.setStrokeWidth(2);
@@ -247,14 +252,14 @@ public class GraphicsAndWindowsTest extends Application {
            slingLine.setStartY(anchorY);
            slingLine.setEndX(anchorX);
            slingLine.setEndY(anchorY);
            group3D.getChildren().add(slingLine);
            layers.getChildren().add(slingLine);
        });

        /*
        Mouse event for drawing line as the mouse is dragged through the window.
         */

        ourWindow.setOnMouseDragged(mouseEvent -> {
        layers.setOnMouseDragged(mouseEvent -> {
            double dragX = mouseEvent.getX();
            double dragY = mouseEvent.getY();
            //System.out.println("Mouse dragged to: " + dragX + ", " + dragY);
@@ -268,10 +273,10 @@ public class GraphicsAndWindowsTest extends Application {
        Mouse event to launch object and delete the slingLine drawn on window.
         */

        ourWindow.setOnMouseReleased(mouseEvent -> {
        layers.setOnMouseReleased(mouseEvent -> {
            releaseX = mouseEvent.getX();
            releaseY = mouseEvent.getY();
            //System.out.println("Mouse released at: " + releaseX + ", " + releaseY);
            System.out.println("Mouse released at: " + releaseX + ", " + releaseY);

            for (MovingObject o : objects ) {
                double x = releaseX -anchorX;
@@ -282,7 +287,7 @@ public class GraphicsAndWindowsTest extends Application {
            }

            // Remove the sling visualization line
            group3D.getChildren().remove(slingLine);
            layers.getChildren().remove(slingLine);

        });