mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge branch 'develop' into Story34_Sparklines
# Conflicts: # src/main/java/seng302/controllers/CanvasController.java
This commit is contained in:
@@ -120,6 +120,9 @@ public class CanvasController {
|
|||||||
initializeMarks();
|
initializeMarks();
|
||||||
timer = new AnimationTimer() {
|
timer = new AnimationTimer() {
|
||||||
|
|
||||||
|
private int UPDATE_FPM_PERIOD = 50; // update FPM label every 50 frames
|
||||||
|
private int updateFPMCounter = 100;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(long now) {
|
public void handle(long now) {
|
||||||
|
|
||||||
@@ -135,7 +138,10 @@ public class CanvasController {
|
|||||||
elapsedNanos = now - oldFrameTime ;
|
elapsedNanos = now - oldFrameTime ;
|
||||||
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ;
|
long elapsedNanosPerFrame = elapsedNanos / frameTimes.length ;
|
||||||
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
|
frameRate = 1_000_000_000.0 / elapsedNanosPerFrame ;
|
||||||
|
if (updateFPMCounter++ > UPDATE_FPM_PERIOD) {
|
||||||
|
updateFPMCounter = 0;
|
||||||
drawFps(frameRate.intValue());
|
drawFps(frameRate.intValue());
|
||||||
|
}
|
||||||
raceViewController.updateSparkLine();
|
raceViewController.updateSparkLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,17 +355,14 @@ public class CanvasController {
|
|||||||
|
|
||||||
private void drawFps(int fps){
|
private void drawFps(int fps){
|
||||||
if (raceViewController.isDisplayFps()){
|
if (raceViewController.isDisplayFps()){
|
||||||
gc.clearRect(5,5,50,20);
|
gc.clearRect(5, 5, 60, 30);
|
||||||
gc.setFill(Color.SKYBLUE);
|
gc.setFont(new Font(16));
|
||||||
gc.fillRect(4,4,51,21);
|
gc.setLineWidth(4);
|
||||||
gc.setFill(Color.BLACK);
|
gc.setGlobalAlpha(0.75);
|
||||||
gc.setFont(new Font(14));
|
|
||||||
gc.setLineWidth(3);
|
|
||||||
gc.fillText(fps + " FPS", 5, 20);
|
gc.fillText(fps + " FPS", 5, 20);
|
||||||
|
gc.setGlobalAlpha(0.5);
|
||||||
} else {
|
} else {
|
||||||
gc.clearRect(5,5,50,20);
|
gc.clearRect(5,5,60,30);
|
||||||
gc.setFill(Color.SKYBLUE);
|
|
||||||
gc.fillRect(4,4,51,21);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user