From 8a7d0e69b2b600d15f0ec3a5edfa6fcef630cce6 Mon Sep 17 00:00:00 2001 From: Antoine Date: Thu, 24 Jun 2021 15:35:49 +0200 Subject: [PATCH] =?UTF-8?q?CameraPushBack=20fonctionne=20=F0=9F=98=8E=20(p?= =?UTF-8?q?our=20de=20vrai=20=F0=9F=A4=9E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gameplay/match/match.java | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 2ddc9d6..cd63df7 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -32,7 +32,6 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import org.lwjgl.glfw.GLFW; import static org.lwjgl.glfw.GLFW.*; @@ -78,7 +77,7 @@ public class match { private static UIElementText timerUI; private static UIElementText fpsCounter; private static UIInputList inputListP1; - private static UIElementText roundWon; + private static UIElementText matchWon; // Debug public static boolean showP1Hitbox; @@ -132,9 +131,9 @@ public class match { String victoryTxt = roundP1 ? "Player1 won the round"+roundCounter : "Player2 won the round"+roundCounter; System.out.println(victoryTxt); - roundWon = new UIElementText(victoryTxt, 5f, 0.25f, 0.5f, 200f, engine); - roundWon.setShader("shaders/StylishShaders/WavyTextVert.glsl", "shaders/StylishShaders/TextFrag.glsl", true, true); - engine.add_uiElement(roundWon); + matchWon = new UIElementText(victoryTxt, 5f, 0.25f, 0.5f, 200f, engine); + matchWon.setShader("shaders/StylishShaders/WavyTextVert.glsl", "shaders/StylishShaders/TextFrag.glsl", true, true); + engine.add_uiElement(matchWon); timeStamp1 = System.currentTimeMillis(); while(System.currentTimeMillis() - timeStamp1 < 2500){ @@ -142,7 +141,7 @@ public class match { engine.render(); } - engine.remove_uiElement(roundWon); + engine.remove_uiElement(matchWon); //replacement des sprites objP1.translate(new Vector3f(-p1.getPosX(), -p1.getPosY())); @@ -158,9 +157,19 @@ public class match { * TODO : Implement this once we know what to do. */ private static void endMatch() { - if (roundsWonP1 > roundsWonP2 ) {System.out.println("P1 won the match");} - else {System.out.println("P1 won the match");} - GLFW.glfwSetWindowShouldClose(Engine.getWindow(), true); + String victoryTxt = roundsWonP1 > roundsWonP2 ? "P1 won the match" : "P2 won the match"; + + matchWon = new UIElementText(victoryTxt, 5f, 0.25f, 0.5f, 200f, engine); + matchWon.setShader("shaders/StylishShaders/WavyTextVert.glsl", "shaders/StylishShaders/TextFrag.glsl", true, true); + engine.add_uiElement(matchWon); + + timeStamp1 = System.currentTimeMillis(); + while(System.currentTimeMillis() - timeStamp1 < 2500){ + engine.update(); + engine.render(); + } + + engine.setRunning(false); } public static void parse() throws FileNotFoundException { @@ -798,11 +807,9 @@ public class match { boolean rightOOB = right.getPosX() + rightObj.getWidth() * rightObj.getScalingFactor() > -engine.getViewXPos() + engine.getCamera().getDimension(); if(leftOOB && rightOutOfView - leftOutOfView > 0){ - System.out.println("Left: " + leftOutOfView); left.setPos((int) (left.getPosX() - leftOutOfView), left.getPosY()); } - if(rightOOB && leftOutOfView + rightOutOfView < 0){ - System.out.println("Right: " + rightOutOfView); + if(rightOOB && leftOutOfView - rightOutOfView < 0){ right.setPos((int) (right.getPosX() - rightOutOfView), right.getPosY()); } }