From 242d30b51c3e58a881dd3aadd34e89b61f298927 Mon Sep 17 00:00:00 2001 From: Antoine Date: Fri, 25 Jun 2021 15:52:25 +0200 Subject: [PATCH] activate debug mode with d key --- src/main/java/engine/input/KeyboardInput.java | 3 ++ src/main/java/gameplay/match/match.java | 48 +++++++++++++------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/main/java/engine/input/KeyboardInput.java b/src/main/java/engine/input/KeyboardInput.java index 4ea08c9..96c75e7 100644 --- a/src/main/java/engine/input/KeyboardInput.java +++ b/src/main/java/engine/input/KeyboardInput.java @@ -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) { diff --git a/src/main/java/gameplay/match/match.java b/src/main/java/gameplay/match/match.java index 50e763b..0e6c6ec 100644 --- a/src/main/java/gameplay/match/match.java +++ b/src/main/java/gameplay/match/match.java @@ -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 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; + } + } + }