Commit c82ffeb2 authored by Louis  Jimenez-Hernandez's avatar Louis Jimenez-Hernandez
Browse files

Added ScoreLabel

parent 91b0f70e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
    </option>
    <option name="workspaceImportForciblyTurnedOn" value="true" />
  </component>
  <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" 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
+9 −1
Original line number Diff line number Diff line
@@ -139,12 +139,16 @@ public class GraphicsAndWindowsTest extends Application {
        Label fpsLabel = new Label("FPS: 0");
        fpsLabel.setTextFill(Color.WHITE);

        Label scoreLabel = new Label("Score: 0");
        fpsLabel.setTextFill(Color.WHITE);
        //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);
        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


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

@@ -157,6 +161,7 @@ public class GraphicsAndWindowsTest extends Application {
            private long lastUpdate = 0; //Movement timer
            private long fpsTimer = 0; //Frame timer
            private long frameRate = 0; //Frames per second
            private long score = 0; //Frames per second



@@ -302,7 +307,10 @@ public class GraphicsAndWindowsTest extends Application {
                    fpsLabel.setText(String.format("FPS: %d", frameRate));
                    frameRate = 0; // Reset frame count
                    fpsTimer = now; // Reset the FPS timer
                    score++;
                    scoreLabel.setText(String.format("Score: %d", score));
                }

            }
        };
        timer.start();