From f3ab1e4c4d487140f48fa5ff4565a14d4704bfe8 Mon Sep 17 00:00:00 2001 From: Antoine Date: Mon, 14 Jun 2021 18:38:37 +0200 Subject: [PATCH] Removed STICKY property in SetTextureWrap --- shaders/StylishShaders/WavyTextVert.glsl | 4 ++-- src/engine/TestEngine.java | 10 +++++----- src/engine/input/KeyboardInput.java | 8 ++++---- src/engine/object/ObjectGl.java | 16 ++-------------- src/engine/object/Text.java | 6 +++--- src/gameplay/Characters/Blue/BlueBaseFrames.java | 2 +- src/gameplay/match/match.java | 12 ++++++------ 7 files changed, 23 insertions(+), 35 deletions(-) diff --git a/shaders/StylishShaders/WavyTextVert.glsl b/shaders/StylishShaders/WavyTextVert.glsl index 8726824..98192cd 100644 --- a/shaders/StylishShaders/WavyTextVert.glsl +++ b/shaders/StylishShaders/WavyTextVert.glsl @@ -16,8 +16,8 @@ uniform float time; void main() { - float speed = 10f; - float amplitude = 4f; + float speed = 5f; + float amplitude = 10f; vec3 newPos = aPos; newPos.y = newPos.y + (sin((time + index * 10f + newPos.x) * speed) * amplitude); gl_Position = projection * view * transform * vec4(newPos, 1.0); diff --git a/src/engine/TestEngine.java b/src/engine/TestEngine.java index 195b3bb..6225628 100644 --- a/src/engine/TestEngine.java +++ b/src/engine/TestEngine.java @@ -47,7 +47,7 @@ public class TestEngine { String pathToText = "textures/dejavu10x10_gs_tc.png"; ObjectGl zangief = new Sprite(10.0f, 10f, path, null); - zangief.setTextureWrap(58, 0, 62, 84, ObjectGl.DEFAULT); + zangief.setTextureWrap(58, 0, 62, 84); engine.add_objectGl(zangief); zangief.translate(new Vector3f(-1000.0f, 200.0f, 0.0f)); zangief.setColor(new Vector3f(1.0f, 1.0f, 1.0f)); @@ -55,7 +55,7 @@ public class TestEngine { zangief.useTime = true; ObjectGl zangief2 = new Sprite(9.0f, 10f, path, null); - zangief2.setTextureWrap(58, 0, 62, 84, ObjectGl.DEFAULT); + zangief2.setTextureWrap(58, 0, 62, 84); engine.add_objectGl(zangief2); zangief2.translate(new Vector3f(1000.0f, 200.0f, 0.0f)); zangief2.flipTextureWrapH(); @@ -67,7 +67,7 @@ public class TestEngine { //Create background ObjectGl background = new ObjectGl(0f,1f,1f,10f, pathToBG, null); - background.setTextureWrap(0,0,621, 224, ObjectGl.DEFAULT); + background.setTextureWrap(0,0,621, 224); background.translate(new Vector3f(-3011.0f, 1400.0f, 1.0f)); engine.add_objectGl(background); @@ -82,8 +82,8 @@ public class TestEngine { UIElementText uiTextCoordP1 = new UIElementText("Boulevard Combattant", 7.0f, 0.0f,0.05f, 25.0f, engine); engine.add_uiElement(uiTextCoordP1); - HorizontalProgressBar healthP1 = new HorizontalProgressBar(50f, 10, 1, 100, 100, 100, false); - UIElement healthP1UI = new UIElement(healthP1, 0f, 1f, engine); + HorizontalProgressBar healthP1 = new HorizontalProgressBar(50f, 9, 1, 100, 100, 100, true); + UIElement healthP1UI = new UIElement(healthP1, 0.005f, 0.995f, engine); engine.add_uiElement(healthP1UI); float hpCurrent = 100; diff --git a/src/engine/input/KeyboardInput.java b/src/engine/input/KeyboardInput.java index b68fa44..5356a5d 100644 --- a/src/engine/input/KeyboardInput.java +++ b/src/engine/input/KeyboardInput.java @@ -33,21 +33,21 @@ public class KeyboardInput extends GLFWKeyCallback { public static void keyboardInput(ObjectGl token, int speed) { boolean keyPressed = false; if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_S)) { - token.setTextureWrap(161,260,56,59, ObjectGl.STICK_BOTTOM); + token.setTextureWrap(161,260,56,59); keyPressed = true; } else if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_W)) { keyPressed = true; } if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_A)) { token.translate(new Vector3f (speed * -1.0f, 0.0f, 0.0f)); - token.setTextureWrap(121,0,57,82, ObjectGl.STICK_TOP); + token.setTextureWrap(121,0,57,82); keyPressed = true; } else if (KeyboardInput.isKeyDown(GLFW.GLFW_KEY_D)) { token.translate(new Vector3f (speed * 1.0f, 0.0f, 0.0f)); - token.setTextureWrap(178,0,62,82, ObjectGl.STICK_TOP); + token.setTextureWrap(178,0,62,82); keyPressed = true; } - if (!keyPressed) token.setTextureWrap(58,0,62,82, ObjectGl.STICK_TOP); + if (!keyPressed) token.setTextureWrap(58,0,62,82); } } diff --git a/src/engine/object/ObjectGl.java b/src/engine/object/ObjectGl.java index 994169c..fc9119a 100644 --- a/src/engine/object/ObjectGl.java +++ b/src/engine/object/ObjectGl.java @@ -163,25 +163,13 @@ public class ObjectGl { } /** - * Change the wrapping coordinate + * Change the wrapping coordinate, beware every sprite have to be of the same size if you don't want strange behavior * @param x starting wrapping on the horizontal axis * @param y starting wrapping on the vertical axis * @param w the length of the wrapping on the horizontal axis * @param h the length of the wrapping on the vertical axis */ - public void setTextureWrap(float x, float y, float w, float h, int sticky){ - // TODO set sticky property + precision issue - if (this.stick_state != sticky){ // Check if we're using a new dimension - if (sticky == STICK_BOTTOM){ - this.stick_state = STICK_BOTTOM; - this.translate(new Vector3f(0.0f, (h - this.height)*this.scalingFactor, 0.0f)); - } else if (sticky == STICK_TOP){ - this.stick_state = STICK_TOP; - this.translate(new Vector3f(0.0f, (h - this.height)*this.scalingFactor, 0.0f)); - } else { - this.stick_state = DEFAULT; - } - } + public void setTextureWrap(float x, float y, float w, float h){ this.height = h; this.width = w; this.vertexArray.swapVertexBufferObject(Primitive.createRectangle(this.zPos, w, h)); diff --git a/src/engine/object/Text.java b/src/engine/object/Text.java index 764c352..ffd7d1b 100644 --- a/src/engine/object/Text.java +++ b/src/engine/object/Text.java @@ -109,13 +109,13 @@ public class Text { private void ObjectGlSetCharWrap(char a, ObjectGl obj){ if (a < 132 && a > 96){ - obj.setTextureWrap(0.0f + (a - 97) * 10.0f,40.0f,10.0f,10.0f, ObjectGl.DEFAULT); + obj.setTextureWrap(0.0f + (a - 97) * 10.0f,40.0f,10.0f,10.0f); } else if (a < 91 && a > 64){ - obj.setTextureWrap(0.0f + (a - 65) * 10.0f,30.0f,10.0f,10.0f, ObjectGl.DEFAULT); + obj.setTextureWrap(0.0f + (a - 65) * 10.0f,30.0f,10.0f,10.0f); } else if (a < 64 && a > 31){ - obj.setTextureWrap(0.0f + (a - 32) * 10.0f,0.0f,10.0f,10.0f, ObjectGl.DEFAULT); + obj.setTextureWrap(0.0f + (a - 32) * 10.0f,0.0f,10.0f,10.0f); } } diff --git a/src/gameplay/Characters/Blue/BlueBaseFrames.java b/src/gameplay/Characters/Blue/BlueBaseFrames.java index d8ebe93..270ecc6 100644 --- a/src/gameplay/Characters/Blue/BlueBaseFrames.java +++ b/src/gameplay/Characters/Blue/BlueBaseFrames.java @@ -321,7 +321,7 @@ public class BlueBaseFrames { Frame f = generateStandFrame1(); ObjectGl blue = new ObjectGl(0f, 60f, 80f, 5f, path, null); - blue.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP); + blue.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]); blue.translate(new Vector3f(-750,200,0)); int posX = -750; int posY = 200; diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 3d99515..bb4541d 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -41,7 +41,7 @@ public class match { /** * the level of the "ground", used to determine if a character is in the air or not. */ - private static final int groundLevel = -400; + private static final int groundLevel = 180; private static int timer; private static InputBuffer inputsP1, inputsP2; @@ -105,7 +105,7 @@ public class match { String pathToBG = "textures/background_beach.png"; ObjectGl background = new ObjectGl(0f,1f,1f,10f, pathToBG, null); - background.setTextureWrap(0,0,621, 224, ObjectGl.DEFAULT); + background.setTextureWrap(0,0,621, 224); background.translate(new Vector3f(-3011.0f, 1400.0f, 1.0f)); engine.add_objectGl(background); @@ -118,10 +118,10 @@ public class match { engine.add_objectGl(objP2); f = p1.getCurrentframe(); - objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP); + objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]); f = p2.getCurrentframe(); - objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP); + objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]); objP2.flipTextureWrapH(); if(Joystick1Present) { @@ -227,10 +227,10 @@ public class match { updatePos(p1); updatePos(p2); f = p1.getCurrentframe(); - objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP); + objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]); objP1.translate(new Vector3f(p1.getPosX()-oldPosXp1,p1.getPosY()-oldPosYp1,0)); f = p2.getCurrentframe(); - objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP); + objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]); objP2.translate(new Vector3f(p2.getPosX()-oldPosXp2,p2.getPosY()-oldPosYp2,0)); boolean p1LooksRight = p1.getPosX() < p2.getPosX();