From 11639912adf05a02f8e8060cbe871f46f8ffe80e Mon Sep 17 00:00:00 2001 From: Antoine Date: Sun, 20 Jun 2021 17:00:35 +0200 Subject: [PATCH 1/3] correction hitbox qui clignote --- src/gameplay/Characters/Blue/BlueNormals.java | 4 +++- src/gameplay/Characters/Blue/BlueSpecials.java | 1 - src/gameplay/frames/Frame.java | 6 ++++++ src/gameplay/match/match.java | 9 +++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gameplay/Characters/Blue/BlueNormals.java b/src/gameplay/Characters/Blue/BlueNormals.java index 7b030e6..055e188 100644 --- a/src/gameplay/Characters/Blue/BlueNormals.java +++ b/src/gameplay/Characters/Blue/BlueNormals.java @@ -251,12 +251,14 @@ public class BlueNormals { Passive_HitBox phb1 = new Passive_HitBox(70,70,150,500); Passive_throw_HitBox pthb1 = new Passive_throw_HitBox(70,400,150,100); Push_HitBox pushB = new Push_HitBox(70,70,150,500); +// Active_HitBox act1 = new Active_HitBox(70,70,150,500); /* adding hitboxes to lists */ phb.add(phb1); pthb.add(pthb1); +// ahb.add(act1); /* frame creation @@ -711,7 +713,7 @@ public class BlueNormals { public static Attack blueFordwardRoundHouse() { ButtonIG[][] cmd = {{FORWARD,D}}; - boolean isSpecial = false; + boolean isSpecial = false; Status rS = Status.NORMAL; attackPart[] parts = {blueForwardDstartup(),blueForwardDactive(),blueForwardDactive2(),blueForwardDrecovery()}; return new Attack(isSpecial,rS,cmd,parts); diff --git a/src/gameplay/Characters/Blue/BlueSpecials.java b/src/gameplay/Characters/Blue/BlueSpecials.java index f5a0cac..73f6937 100644 --- a/src/gameplay/Characters/Blue/BlueSpecials.java +++ b/src/gameplay/Characters/Blue/BlueSpecials.java @@ -252,5 +252,4 @@ public class BlueSpecials { return new Attack(isSpecial,rS,cmd,parts); } - } diff --git a/src/gameplay/frames/Frame.java b/src/gameplay/frames/Frame.java index 2a11b0a..7d5e796 100644 --- a/src/gameplay/frames/Frame.java +++ b/src/gameplay/frames/Frame.java @@ -25,6 +25,7 @@ public class Frame { private boolean moveCancellable; private boolean isDashCancellable; private boolean lastFrameOfHit; + private boolean isInverted; /** * an int of 4 that determines the texture wrap for the frame */ @@ -164,6 +165,10 @@ public class Frame { this.lastFrameOfHit = lastFrameOfHit; } + public boolean getIsInverted(){ + return this.isInverted; + } + //Inverts all hitboxes of the frame horizontally. Used if the character looks to the left instead of the right public void invertHitBoxes() { for(Passive_HitBox p: this.passHitBox) {p.reverseHorizontally();} @@ -171,6 +176,7 @@ public class Frame { for(Passive_throw_HitBox p: this.passThrowHitBox) {p.reverseHorizontally();} for(Active_throw_Hitbox p: this.actThrowHitBox) {p.reverseHorizontally();} this.pushHitBox.reverseHorizontally(); + isInverted = true; } public void clone(Frame f) { diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index de9feb6..8cfe634 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -318,6 +318,14 @@ public class match { if(p2.getCurrentframe().islastFrameOfHit()) { p2.removeFirstAttackPart(); } + + //Si la frame d'avant est inversé il faut la "nettoyer" pour le prochaine utilisation + if (p1.getCurrentframe().getIsInverted()){ + p1.getCurrentframe().invertHitBoxes(); + } if (p2.getCurrentframe().getIsInverted()){ + p2.getCurrentframe().invertHitBoxes(); + + } nextFrame(p1,inputsP1); nextFrame(p2,inputsP2); @@ -358,6 +366,7 @@ public class match { objP1.flipTextureWrapH(); } + // Debug Hitbox Management removeHitboxEngine(); if (showP1Hitbox){ From c1a696ae1c5d134d1174c4b10ad85c3c38c93756 Mon Sep 17 00:00:00 2001 From: Antoine Date: Sun, 20 Jun 2021 17:04:21 +0200 Subject: [PATCH 2/3] =?UTF-8?q?comment=C3=A9=20le=20clonage=20de=20la=20fr?= =?UTF-8?q?ame=20dans=20le=20processus=20d'inversion=20d'une=20hitbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gameplay/frames/Frame.java | 2 +- src/gameplay/match/match.java | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gameplay/frames/Frame.java b/src/gameplay/frames/Frame.java index 7d5e796..07d5700 100644 --- a/src/gameplay/frames/Frame.java +++ b/src/gameplay/frames/Frame.java @@ -179,7 +179,7 @@ public class Frame { isInverted = true; } - public void clone(Frame f) { + public void clone(Frame f) { //TODO le clonage ne fonctionne pas certain paramètre renvoie toujours le pointeur vers un objet this.setMove_y(f.getMove_y()); this.setMove_x(f.getMove_x()); this.setPassHitBox(f.getPassHitBox()); diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 8cfe634..7a80f74 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -343,10 +343,11 @@ public class match { 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)); - Frame nf = new Frame(); - nf.clone(p2.getCurrentframe()); - nf.invertHitBoxes(); - p2.setCurrentFrame(nf); +// Frame nf = new Frame(); //TODO dans l'état le clonage ne fonctionne pas +// nf.clone(p2.getCurrentframe()); +// nf.invertHitBoxes(); +// p2.setCurrentFrame(nf); + f.invertHitBoxes(); objP2.flipTextureWrapH(); } else { @@ -359,10 +360,11 @@ public class match { objP2.setTextureWrap(p2f.getSprite()[0], p2f.getSprite()[1], p2f.getSprite()[2], p2f.getSprite()[3]); objP2.translate(new Vector3f(p2.getPosX()-oldPosXp2,p2.getPosY()-oldPosYp2,0)); - Frame nf = new Frame(); - nf.clone(p1.getCurrentframe()); - nf.invertHitBoxes(); - p1.setCurrentFrame(nf); +// Frame nf = new Frame(); +// nf.clone(p1.getCurrentframe()); +// nf.invertHitBoxes(); +// p1.setCurrentFrame(nf); + p1f.invertHitBoxes(); objP1.flipTextureWrapH(); } From e6605bec947f149e8d7e2c0e96b8e934d97f99c5 Mon Sep 17 00:00:00 2001 From: Antoine Date: Sun, 20 Jun 2021 18:46:36 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Clonage=20r=C3=A9par=C3=A9=20on=20skip=20to?= =?UTF-8?q?ujours=20la=20premi=C3=A8re=20frame=20d'une=20suite=20pour=20l'?= =?UTF-8?q?inversion...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gameplay/frames/Frame.java | 36 ++++++++++++++++++++++------------ src/gameplay/match/match.java | 25 ++++++++--------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/gameplay/frames/Frame.java b/src/gameplay/frames/Frame.java index 07d5700..7a94eb9 100644 --- a/src/gameplay/frames/Frame.java +++ b/src/gameplay/frames/Frame.java @@ -25,7 +25,7 @@ public class Frame { private boolean moveCancellable; private boolean isDashCancellable; private boolean lastFrameOfHit; - private boolean isInverted; + /** * an int of 4 that determines the texture wrap for the frame */ @@ -165,10 +165,6 @@ public class Frame { this.lastFrameOfHit = lastFrameOfHit; } - public boolean getIsInverted(){ - return this.isInverted; - } - //Inverts all hitboxes of the frame horizontally. Used if the character looks to the left instead of the right public void invertHitBoxes() { for(Passive_HitBox p: this.passHitBox) {p.reverseHorizontally();} @@ -176,17 +172,14 @@ public class Frame { for(Passive_throw_HitBox p: this.passThrowHitBox) {p.reverseHorizontally();} for(Active_throw_Hitbox p: this.actThrowHitBox) {p.reverseHorizontally();} this.pushHitBox.reverseHorizontally(); - isInverted = true; } - public void clone(Frame f) { //TODO le clonage ne fonctionne pas certain paramètre renvoie toujours le pointeur vers un objet + public void clone(Frame f) { this.setMove_y(f.getMove_y()); this.setMove_x(f.getMove_x()); - this.setPassHitBox(f.getPassHitBox()); - this.setActHitBox(f.getActHitBox()); - this.setPassThrowHitBox(f.getPassThrowHitBox()); - this.setActThrowHitBox(f.getActThrowHitBox()); - this.setPushHitBox(f.getPushHitBox()); + this.cloneArray(f); //Il faut cloner individuellement chaque hitbox des differentes listes pour ne pas garder les pointeurs + Push_HitBox phb = f.getPushHitBox(); + this.setPushHitBox(new Push_HitBox(phb.getPosX(), phb.getPosY(), phb.getSize_x(), phb.getSize_y())); this.normalCancellable = f.isNormalCancellable(); this.specialCancellable = f.isSpecialCancellable(); this.jumpCancellable = f.jumpCancellable; @@ -196,6 +189,25 @@ public class Frame { this.setSpriteWrap(f.sprite[0], f.sprite[1], f.sprite[2], f.sprite[3]); } + private void cloneArray(Frame f){ + for (Passive_HitBox hb : f.getPassHitBox()){ + Passive_HitBox nhb = new Passive_HitBox(hb.getPosX(), hb.getPosY(), hb.getSize_x(), hb.getSize_y()); + this.passHitBox.add(nhb); + } + for (Passive_throw_HitBox hb : f.getPassThrowHitBox()){ + Passive_throw_HitBox nhb = new Passive_throw_HitBox(hb.getPosX(), hb.getPosY(), hb.getSize_x(), hb.getSize_y()); + this.passThrowHitBox.add(nhb); + } + for (Active_HitBox hb : f.getActHitBox()){ + Active_HitBox nhb = new Active_HitBox(hb.getPosX(), hb.getPosY(), hb.getSize_x(), hb.getSize_y()); + this.actHitBox.add(nhb); + } + for (Active_throw_Hitbox hb : f.getActThrowHitBox()){ + Active_throw_Hitbox nhb = new Active_throw_Hitbox(hb.getPosX(), hb.getPosY(), hb.getSize_x(), hb.getSize_y()); + this.actThrowHitBox.add(nhb); + } + } + /** * sets the coordinates on the spritesheet for the texture for that frame * @param x coordinate of the lef tside diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 7a80f74..b0112d7 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -319,13 +319,6 @@ public class match { p2.removeFirstAttackPart(); } - //Si la frame d'avant est inversé il faut la "nettoyer" pour le prochaine utilisation - if (p1.getCurrentframe().getIsInverted()){ - p1.getCurrentframe().invertHitBoxes(); - } if (p2.getCurrentframe().getIsInverted()){ - p2.getCurrentframe().invertHitBoxes(); - - } nextFrame(p1,inputsP1); nextFrame(p2,inputsP2); @@ -343,11 +336,10 @@ public class match { 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)); -// Frame nf = new Frame(); //TODO dans l'état le clonage ne fonctionne pas -// nf.clone(p2.getCurrentframe()); -// nf.invertHitBoxes(); -// p2.setCurrentFrame(nf); - f.invertHitBoxes(); + Frame nf = new Frame(); + nf.clone(p2.getCurrentframe()); + nf.invertHitBoxes(); + p2.setCurrentFrame(nf); objP2.flipTextureWrapH(); } else { @@ -360,11 +352,10 @@ public class match { objP2.setTextureWrap(p2f.getSprite()[0], p2f.getSprite()[1], p2f.getSprite()[2], p2f.getSprite()[3]); objP2.translate(new Vector3f(p2.getPosX()-oldPosXp2,p2.getPosY()-oldPosYp2,0)); -// Frame nf = new Frame(); -// nf.clone(p1.getCurrentframe()); -// nf.invertHitBoxes(); -// p1.setCurrentFrame(nf); - p1f.invertHitBoxes(); + Frame nf = new Frame(); + nf.clone(p1.getCurrentframe()); + nf.invertHitBoxes(); + p1.setCurrentFrame(nf); objP1.flipTextureWrapH(); }