fpsCounter added

This commit is contained in:
Antoine 2021-06-20 22:16:49 +02:00
parent 6325f76942
commit 37e4771d95
2 changed files with 20 additions and 5 deletions

View File

@ -6,6 +6,7 @@ import gameplay.frames.nextFrameBuffer;
import gameplay.input.InputBuffer;
import java.util.ArrayList;
import java.util.Arrays;
/**
* Character class, which is a sub-class of an entity
@ -206,9 +207,7 @@ public class Character extends Entity {
public void setAttackPartsArray(attackPart[] parts) {
this.nextAttackParts = new ArrayList<attackPart>();
for(int i = 0; i < parts.length; i++) {
this.nextAttackParts.add(parts[i]);
}
this.nextAttackParts.addAll(Arrays.asList(parts));
}
/**

View File

@ -78,6 +78,7 @@ public class match {
private static HorizontalProgressBar healthBarP1Obj;
private static HorizontalProgressBar healthBarP2Obj;
private static UIElementText timerUI;
private static UIElementText fpsCounter;
private static UIInputList inputListP1;
// Debug
@ -85,6 +86,8 @@ public class match {
private static boolean showP2Hitbox = true;
private static List<Hitbox> listHitboxObj = new ArrayList<>();
private static float slowFactor = 1f;
private static long timeStampFpsCounter;
private static int frameCounter;
private static Sprite objP1,objP2;
private static Engine engine;
@ -226,6 +229,11 @@ public class match {
// Timer
timerUI = new UIElementText(timer + "", 10f, 0.453f, 0.995f, 85f, engine);
engine.add_uiElement(timerUI);
// FPS counter
fpsCounter = new UIElementText("Boulevard Combattant", 5f, 0f, 0.04f, 100f, engine);
fpsCounter.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(fpsCounter);
timeStampFpsCounter = System.currentTimeMillis();
//SetTracking
engine.setCameraTrackingSF3ThirdStrike(objP1, objP2);
@ -390,9 +398,17 @@ public class match {
timer = 99 - frameCount/60;
timeStamp2 = System.currentTimeMillis();
while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) {
timeStamp2 = System.currentTimeMillis();
// while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) {
// timeStamp2 = System.currentTimeMillis();
// }
frameCounter++;
if (System.currentTimeMillis() - timeStampFpsCounter >= 1000){
fpsCounter.setText("FPS: " + frameCounter);
frameCounter = 0;
timeStampFpsCounter = System.currentTimeMillis();
}
frameCount++;
timeStamp1 = System.currentTimeMillis();
acCode=10;