From cbec6fba9d39967afe695d40425faeeb7238a518 Mon Sep 17 00:00:00 2001 From: Antoine Date: Wed, 16 Jun 2021 13:48:52 +0200 Subject: [PATCH] =?UTF-8?q?Montre=20les=20coordonn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shaders/StylishShaders/FlashFrag.glsl | 4 ++-- src/engine/TestEngine.java | 8 ++++++-- src/gameplay/match/match.java | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/shaders/StylishShaders/FlashFrag.glsl b/shaders/StylishShaders/FlashFrag.glsl index 3362434..85e3f95 100644 --- a/shaders/StylishShaders/FlashFrag.glsl +++ b/shaders/StylishShaders/FlashFrag.glsl @@ -15,12 +15,12 @@ void main(){ flash = sin(flash + time * 15); flash = mix(flash, color, 0.5f); + flash.a = 1f; vec4 tex = texture(texture1, texCoord); - if (tex.a == 0.0){ + if (tex.a == 0.0 || (flash.x+ flash.y + flash.z)/3 <= (tex.x+ tex.y + tex.z)/3){ FragColor = tex; } else{ FragColor = mix(tex, flash, 0.3f); - FragColor.a = 1.0f; } } diff --git a/src/engine/TestEngine.java b/src/engine/TestEngine.java index 6225628..61b98cc 100644 --- a/src/engine/TestEngine.java +++ b/src/engine/TestEngine.java @@ -49,7 +49,7 @@ public class TestEngine { ObjectGl zangief = new Sprite(10.0f, 10f, path, null); zangief.setTextureWrap(58, 0, 62, 84); engine.add_objectGl(zangief); - zangief.translate(new Vector3f(-1000.0f, 200.0f, 0.0f)); + zangief.translate(new Vector3f(-750.0f, 200.0f, 0.0f)); zangief.setColor(new Vector3f(1.0f, 1.0f, 1.0f)); zangief.setShader("shaders/StylishShaders/BasicVert.glsl", "shaders/StylishShaders/FlashFrag.glsl"); zangief.useTime = true; @@ -57,9 +57,13 @@ public class TestEngine { ObjectGl zangief2 = new Sprite(9.0f, 10f, path, null); zangief2.setTextureWrap(58, 0, 62, 84); engine.add_objectGl(zangief2); - zangief2.translate(new Vector3f(1000.0f, 200.0f, 0.0f)); + zangief2.translate(new Vector3f(500.0f, 200.0f, 0.0f)); zangief2.flipTextureWrapH(); + ObjectGl shaderTestSubject = new ObjectGl(24f, 10f, 10f, 100f, null, null); + shaderTestSubject.translate(new Vector3f(-200f, 400f, 0f)); + engine.add_objectGl(shaderTestSubject); + // Hitbox hitboxTest = new Hitbox(35.0f, 100.0f, 50.0f, 10.0f, new Vector3f(1.0f, 0.0f, 0.0f)); // engine.add_objectGl(hitboxTest); diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 376eb7e..0f54422 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -1,6 +1,7 @@ package gameplay.match; import engine.Engine; +import engine.gui.UIElementText; import engine.input.Button; import engine.input.GamepadInput; import engine.math.Vector3f; @@ -58,6 +59,10 @@ public class match { private static GamepadInput gamepad1 = null; private static GamepadInput gamepad2 = null; + // GUI + private static UIElementText coordP1; + private static UIElementText coordP2; + private static ObjectGl objP1,objP2; private static Engine engine; private static Frame f; @@ -135,6 +140,12 @@ public class match { System.out.println("P2 Controller: " + gamepad2.getGamepadName()); } + // GUI setup + coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 1f, 80f, engine); + engine.add_uiElement(coordP1); + coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.9f, 80f, engine); + engine.add_uiElement(coordP2); + while(frameCount < 5940 && engine.getRunning()) { ac(acCode); if(engine.shouldClose()) engine.setRunning(false); @@ -272,6 +283,9 @@ public class match { //Waits the end of 1/60th of a second since start of frame then loops back to start case 23: + // GUI update here + coordP1.setText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY()); + coordP2.setText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P2: " + p2.getPosX() +":" + p2.getPosY()); timeStamp2 = System.currentTimeMillis(); while(timeStamp2-timeStamp1<(1000/60)) { timeStamp2 = System.currentTimeMillis();