diff --git a/src/gameplay/frames/Frame.java b/src/gameplay/frames/Frame.java index 7a94eb9..2d0421b 100644 --- a/src/gameplay/frames/Frame.java +++ b/src/gameplay/frames/Frame.java @@ -225,4 +225,22 @@ public class Frame { public int[] getSprite() { return sprite; } + + /** + * This becomes a clone of a given frame, except for the movement data. + * Usueful for jump attack + * @param f the frame to clone + */ + public void cloneWithoutMovement(Frame f) { + 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; + this.moveCancellable = f.isMoveCancellable(); + this.isDashCancellable = f.isDashCancellable; + this.lastFrameOfHit = f.islastFrameOfHit(); + this.setSpriteWrap(f.sprite[0], f.sprite[1], f.sprite[2], f.sprite[3]); + } } diff --git a/src/gameplay/frames/nextFrameBuffer.java b/src/gameplay/frames/nextFrameBuffer.java index f9ac911..c87919f 100644 --- a/src/gameplay/frames/nextFrameBuffer.java +++ b/src/gameplay/frames/nextFrameBuffer.java @@ -1,5 +1,7 @@ package gameplay.frames; +import java.util.ArrayList; + /** * This will handle the next frames to be played by each entity. * @author Victor Azra @@ -76,4 +78,25 @@ public class nextFrameBuffer { } } + /** + * Copies the same amount of frames from f in this, as the amount originally present, but keepsoriginal move data + * @param f frames array to copy + */ + public void changeFramesExceptForMove(ArrayList f) { + int i = 0; + boolean goOn = true; + nextFrameBuffer fb = new nextFrameBuffer(); + fb.clone(this); + this.emptyQueue(); + try{fb.goToNext();} catch(IndexOutOfBoundsException e) {goOn = false;} + while(goOn && i < f.size()) { + try{ + fb.current.cloneWithoutMovement(f.get(i)); + this.addFrameToQueue(fb.current); + fb.goToNext(); + i++; + } catch(IndexOutOfBoundsException e) { goOn = false;} + } + } + } diff --git a/src/gameplay/match/match.java b/src/gameplay/match/match.java index 3a5d3d3..eb4f11a 100644 --- a/src/gameplay/match/match.java +++ b/src/gameplay/match/match.java @@ -18,6 +18,7 @@ import gameplay.actions.Throw; import gameplay.actions.ThrowPart; import gameplay.entities.Status; import gameplay.frames.Frame; +import gameplay.frames.nextFrameBuffer; import gameplay.hitboxes.*; import gameplay.input.InputBuffer; import gameplay.entities.Character; @@ -464,6 +465,12 @@ public class match { && ((atk.isSpecial() && c.getCurrentframe().isSpecialCancellable()) || (!atk.isSpecial() && c.getCurrentframe().isNormalCancellable())); if(attackIsPossible) { + if(c.getStatus() == Status.JUMPING) { + nextFrameBuffer nJumpFb = new nextFrameBuffer(); + nJumpFb.clone(c.getFrames()); + nJumpFb.changeFramesExceptForMove(atk.getFrame()); + c.setFrames(nJumpFb); + } c.clearNextFrames(); c.addNextFramesList(atk.getFrame()); c.setAttackPartsArray(atk.getParts());