From ff16ea1ae988dc33abaa8f20a81b5a7b016a274f Mon Sep 17 00:00:00 2001 From: Antoine Date: Thu, 17 Jun 2021 22:43:51 +0200 Subject: [PATCH] Hitbox reverse pour taille 4 --- src/engine/object/Hitbox.java | 22 ++++++++++++---------- src/gameplay/hitboxes/Active_HitBox.java | 2 +- src/gameplay/hitboxes/HitBox.java | 4 ++-- src/gameplay/hitboxes/Passive_HitBox.java | 2 +- src/gameplay/hitboxes/Push_HitBox.java | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/engine/object/Hitbox.java b/src/engine/object/Hitbox.java index d1aa2bd..67528e7 100644 --- a/src/engine/object/Hitbox.java +++ b/src/engine/object/Hitbox.java @@ -2,20 +2,22 @@ package engine.object; import engine.math.Vector3f; +import static org.lwjgl.glfw.GLFW.glfwGetTime; + public class Hitbox extends ObjectGl{ - - /** - * Create a rectangle shape, use setTextureWrap to correctly align the texture with the model - * - * @param z depth of your model the larger it is the more it will be "close" to the camera - * @param w height of the rectangle - * @param h width of the rectangle - * @param size scaling factor of the rectangle, the model could not show up because this value is too small or too large, a good compromise is between 2 and 15 - * @param color set to null if you don't want a Color on your model - */ public Hitbox(float z, float w, float h, float size, Vector3f color) { super(z, w, h, size, null, color); this.setShader("shaders/ObjectGlColor/vert.glsl", "shaders/StylishShaders/HitboxFrag.glsl"); } + + + + protected void uniformInjection(){ + if (this.useTime) this.shader.setUniform1f("time", (float) glfwGetTime()); + + this.shader.setUniformMat4f("projection", projection); + this.shader.setUniformMat4f("view", view); + this.shader.setUniformMat4f("transform", this.transform); + } } diff --git a/src/gameplay/hitboxes/Active_HitBox.java b/src/gameplay/hitboxes/Active_HitBox.java index 55bc382..d014496 100644 --- a/src/gameplay/hitboxes/Active_HitBox.java +++ b/src/gameplay/hitboxes/Active_HitBox.java @@ -4,7 +4,7 @@ public class Active_HitBox extends HitBox { public Active_HitBox() { super(); } - public Active_HitBox(float posX, float posY, float sizeX, float sizeY) { + public Active_HitBox(float posX, float posY, float sizeX, float sizeY) { super(posX, posY, sizeX, sizeY); } } diff --git a/src/gameplay/hitboxes/HitBox.java b/src/gameplay/hitboxes/HitBox.java index 54cf28f..fafbc86 100644 --- a/src/gameplay/hitboxes/HitBox.java +++ b/src/gameplay/hitboxes/HitBox.java @@ -99,7 +99,7 @@ public class HitBox { } public void reverseHorizontally() { - this.position_x = 0 - position_x; - this.size_x = 0 - this.size_x; + this.position_x = 138*4 - position_x; //Il faut la largeur de la sprite + this.size_x = -this.size_x; } } \ No newline at end of file diff --git a/src/gameplay/hitboxes/Passive_HitBox.java b/src/gameplay/hitboxes/Passive_HitBox.java index bd3279d..17da71f 100644 --- a/src/gameplay/hitboxes/Passive_HitBox.java +++ b/src/gameplay/hitboxes/Passive_HitBox.java @@ -4,7 +4,7 @@ public class Passive_HitBox extends HitBox { public Passive_HitBox() { super(); } - public Passive_HitBox(float posX, float posY, float sizeX, float sizeY) { + public Passive_HitBox(float posX, float posY, float sizeX, float sizeY) { super(posX, posY, sizeX, sizeY); } } diff --git a/src/gameplay/hitboxes/Push_HitBox.java b/src/gameplay/hitboxes/Push_HitBox.java index 3a678a7..d614f99 100644 --- a/src/gameplay/hitboxes/Push_HitBox.java +++ b/src/gameplay/hitboxes/Push_HitBox.java @@ -5,7 +5,7 @@ public class Push_HitBox extends HitBox { public Push_HitBox() { super(); } - public Push_HitBox(float posX, float posY, float sizeX, float sizeY) { + public Push_HitBox(float posX, float posY, float sizeX, float sizeY) { super(posX, posY, sizeX, sizeY); } }