diff --git a/src/main/java/seng302/controllers/CanvasController.java b/src/main/java/seng302/controllers/CanvasController.java index e656039e..87421576 100644 --- a/src/main/java/seng302/controllers/CanvasController.java +++ b/src/main/java/seng302/controllers/CanvasController.java @@ -78,15 +78,19 @@ public class CanvasController { // overriding the handle so that it can clean canvas and redraw boats and course marks AnimationTimer timer = new AnimationTimer() { private long lastUpdate = 0; + private long lastFpsUpdate = 0; + private int lastFpsCount = 0; + private int fpsCount = 0; @Override public void handle(long now) { - if (now - lastUpdate >= 33000000){ + if (true){ //if statement for limiting refresh rate if needed gc.clearRect(0, 0, canvas.getWidth(),canvas.getHeight()); gc.setFill(Color.SKYBLUE); gc.fillRect(0,0,canvas.getWidth(),canvas.getHeight()); drawCourse(); drawBoats(); + drawFps(lastFpsCount); // If race has started, draw the boats and play the timeline if (race.getRaceTime() > 1){ @@ -98,6 +102,12 @@ public class CanvasController { pauseTimelines(); } lastUpdate = now; + fpsCount ++; + if (now - lastFpsUpdate >= 1000000000){ + lastFpsCount = fpsCount; + fpsCount = 0; + lastFpsUpdate = now; + } } } }; @@ -256,6 +266,13 @@ public class CanvasController { } } + private void drawFps(int fps){ + gc.setFill(Color.BLACK); + gc.setFont(new Font(14)); + gc.setLineWidth(3); + gc.fillText(fps + " FPS", 5, 20); + } + /** * Draws all the boats. */ diff --git a/src/main/java/seng302/models/Race.java b/src/main/java/seng302/models/Race.java index 9c21cc0b..a46ddf16 100644 --- a/src/main/java/seng302/models/Race.java +++ b/src/main/java/seng302/models/Race.java @@ -152,7 +152,6 @@ public class Race { * @param boat The boat that has finished the race */ public void setBoatFinished(Boat boat){ - System.out.println(boat.getTeamName() + " finished"); this.finishingOrder.add(boat); }