fpsCounter added
This commit is contained in:
parent
6325f76942
commit
37e4771d95
@ -6,6 +6,7 @@ import gameplay.frames.nextFrameBuffer;
|
|||||||
import gameplay.input.InputBuffer;
|
import gameplay.input.InputBuffer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Character class, which is a sub-class of an entity
|
* Character class, which is a sub-class of an entity
|
||||||
@ -206,9 +207,7 @@ public class Character extends Entity {
|
|||||||
|
|
||||||
public void setAttackPartsArray(attackPart[] parts) {
|
public void setAttackPartsArray(attackPart[] parts) {
|
||||||
this.nextAttackParts = new ArrayList<attackPart>();
|
this.nextAttackParts = new ArrayList<attackPart>();
|
||||||
for(int i = 0; i < parts.length; i++) {
|
this.nextAttackParts.addAll(Arrays.asList(parts));
|
||||||
this.nextAttackParts.add(parts[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,6 +78,7 @@ public class match {
|
|||||||
private static HorizontalProgressBar healthBarP1Obj;
|
private static HorizontalProgressBar healthBarP1Obj;
|
||||||
private static HorizontalProgressBar healthBarP2Obj;
|
private static HorizontalProgressBar healthBarP2Obj;
|
||||||
private static UIElementText timerUI;
|
private static UIElementText timerUI;
|
||||||
|
private static UIElementText fpsCounter;
|
||||||
private static UIInputList inputListP1;
|
private static UIInputList inputListP1;
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
@ -85,6 +86,8 @@ public class match {
|
|||||||
private static boolean showP2Hitbox = true;
|
private static boolean showP2Hitbox = true;
|
||||||
private static List<Hitbox> listHitboxObj = new ArrayList<>();
|
private static List<Hitbox> listHitboxObj = new ArrayList<>();
|
||||||
private static float slowFactor = 1f;
|
private static float slowFactor = 1f;
|
||||||
|
private static long timeStampFpsCounter;
|
||||||
|
private static int frameCounter;
|
||||||
|
|
||||||
private static Sprite objP1,objP2;
|
private static Sprite objP1,objP2;
|
||||||
private static Engine engine;
|
private static Engine engine;
|
||||||
@ -226,6 +229,11 @@ public class match {
|
|||||||
// Timer
|
// Timer
|
||||||
timerUI = new UIElementText(timer + "", 10f, 0.453f, 0.995f, 85f, engine);
|
timerUI = new UIElementText(timer + "", 10f, 0.453f, 0.995f, 85f, engine);
|
||||||
engine.add_uiElement(timerUI);
|
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
|
//SetTracking
|
||||||
engine.setCameraTrackingSF3ThirdStrike(objP1, objP2);
|
engine.setCameraTrackingSF3ThirdStrike(objP1, objP2);
|
||||||
|
|
||||||
@ -390,9 +398,17 @@ public class match {
|
|||||||
timer = 99 - frameCount/60;
|
timer = 99 - frameCount/60;
|
||||||
|
|
||||||
timeStamp2 = System.currentTimeMillis();
|
timeStamp2 = System.currentTimeMillis();
|
||||||
while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) {
|
// while(timeStamp2-timeStamp1<(1000/(60 * slowFactor))) {
|
||||||
timeStamp2 = System.currentTimeMillis();
|
// timeStamp2 = System.currentTimeMillis();
|
||||||
|
// }
|
||||||
|
|
||||||
|
frameCounter++;
|
||||||
|
if (System.currentTimeMillis() - timeStampFpsCounter >= 1000){
|
||||||
|
fpsCounter.setText("FPS: " + frameCounter);
|
||||||
|
frameCounter = 0;
|
||||||
|
timeStampFpsCounter = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
frameCount++;
|
frameCount++;
|
||||||
timeStamp1 = System.currentTimeMillis();
|
timeStamp1 = System.currentTimeMillis();
|
||||||
acCode=10;
|
acCode=10;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user