activate debug mode with d key

This commit is contained in:
Antoine 2021-06-25 15:52:25 +02:00
parent 7c448591ea
commit 242d30b51c
2 changed files with 36 additions and 15 deletions

View File

@ -29,6 +29,9 @@ public class KeyboardInput extends GLFWKeyCallback {
match.showP1Hitbox = !match.showP1Hitbox;
match.showP2Hitbox = !match.showP2Hitbox;
}
else if(key == GLFW_KEY_D && action == GLFW_PRESS){
match.debugToggle();
}
}
public static boolean isKeyDown(int keyCode) {

View File

@ -85,7 +85,7 @@ public class match {
private static int rightBoundary;
// Debug
public static boolean debugMode = true;
public static boolean debugMode = false;
public static boolean showP1Hitbox;
public static boolean showP2Hitbox;
private static List<Hitbox> listHitboxObj = new ArrayList<>();
@ -312,18 +312,9 @@ public class match {
// Timer
timerUI = new UIElementText(timer + "", 10f, 0.453f, 0.995f, 85f, engine);
engine.add_uiElement(timerUI);
if(debugMode){
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 0.15f, 70f, engine);
coordP1.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(coordP1);
coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.1f, 70f, engine);
coordP2.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(coordP2);
// FPS counter
fpsCounter = new UIElementText("Boulevard Combattant", 5f, 0f, 0.04f, 100f, engine);
fpsCounter.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(fpsCounter);
}
debugToggle();
timeStampFpsCounter = System.currentTimeMillis();
//SetTracking
engine.setCameraTrackingSF3ThirdStrike(objP1, objP2);
@ -513,11 +504,11 @@ public class match {
frameCounter++;
if (System.currentTimeMillis() - timeStampFpsCounter >= 1000){
frameCounter = 0;
timeStampFpsCounter = System.currentTimeMillis();
if(debugMode){
fpsCounter.setText("FPS: " + frameCounter);
}
frameCounter = 0;
timeStampFpsCounter = System.currentTimeMillis();
}
frameCount++;
@ -932,4 +923,31 @@ public class match {
}
}
public static void debugToggle(){
if (debugMode){
if(coordP1 != null){
engine.remove_uiElement(coordP1);
}
if(coordP2 != null){
engine.remove_uiElement(coordP2);
}
if(fpsCounter != null){
engine.remove_uiElement(fpsCounter);
}
debugMode = false;
} else {
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 0.15f, 70f, engine);
coordP1.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(coordP1);
coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.1f, 70f, engine);
coordP2.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(coordP2);
// FPS counter
fpsCounter = new UIElementText("Boulevard Combattant", 5f, 0f, 0.04f, 100f, engine);
fpsCounter.setBackground(new Vector3f(0f,0f,0f));
engine.add_uiElement(fpsCounter);
debugMode = true;
}
}
}