package gameplay.frames; import java.util.ArrayList; import engine.graphics.Texture; import gameplay.hitboxes.*; /** * Main class for frames * @author Victor Azra * */ public class Frame { private Double move_y; private Double move_x; private ArrayList passHitBox; private ArrayList actHitBox; private ArrayList passThrowHitBox; private ArrayList actThrowHitBox; private Push_HitBox pushHitBox; private boolean normalCancellable; private boolean specialCancellable; private boolean jumpCancellable; private boolean moveCancellable; private boolean isDashCancellable; private boolean lastFrameOfHit; private boolean isInverted; /** * an int of 4 that determines the texture wrap for the frame */ private int[] sprite; public Frame() { this.setMove_y(0.0); this.setMove_x(0.0); this.setPassHitBox(new ArrayList()); this.setActHitBox(new ArrayList()); this.setPassThrowHitBox(new ArrayList()); this.setActThrowHitBox(new ArrayList()); this.setPushHitBox(new Push_HitBox()); this.normalCancellable = true; this.specialCancellable = true; this.jumpCancellable = true; this.moveCancellable = true; this.isDashCancellable = true; this.lastFrameOfHit = false; this.sprite = new int[4]; } public Frame(Double move_y, Double move_x, ArrayList passHitBox, ArrayList actHitBox, ArrayList passThrowHitBox, ArrayList actThrowHitBox, Push_HitBox pushHitBox, boolean normalCancellable, boolean specialCancellable, boolean jumpCancellable, boolean moveCancellable, boolean isDashCancellable) { this.setMove_y(move_y); this.setMove_x(move_x); this.setPassHitBox(passHitBox); this.setActHitBox(actHitBox); this.setPassThrowHitBox(passThrowHitBox); this.setActThrowHitBox(actThrowHitBox); this.setPushHitBox(pushHitBox); this.normalCancellable = normalCancellable; this.specialCancellable = specialCancellable; this.jumpCancellable = jumpCancellable; this.moveCancellable = moveCancellable; this.isDashCancellable = isDashCancellable; this.lastFrameOfHit = false; this.sprite = new int[4]; } /* * Mainly use for projectiles */ public Frame(Double move_y, Double move_x, ArrayList passHitBox, ArrayList actHitBox) { this.setMove_y(move_y); this.setMove_x(move_x); this.setPassHitBox(passHitBox); this.setActHitBox(actHitBox); this.setPassThrowHitBox(new ArrayList()); this.setActThrowHitBox(new ArrayList()); this.setPushHitBox(new Push_HitBox()); } public boolean isNormalCancellable() { return normalCancellable; } public boolean isSpecialCancellable() { return specialCancellable; } public boolean isJumpCancellable() { return jumpCancellable; } public boolean isMoveCancellable() { return moveCancellable; } public boolean isDashCancellable() { return isDashCancellable; } public Double getMove_y() { return move_y; } public void setMove_y(Double move_y) { this.move_y = move_y; } public Double getMove_x() { return move_x; } public void setMove_x(Double move_x) { this.move_x = move_x; } public ArrayList getPassHitBox() { return passHitBox; } public void setPassHitBox(ArrayList passHitBox) { this.passHitBox = passHitBox; } public ArrayList getActHitBox() { return actHitBox; } public void setActHitBox(ArrayList actHitBox) { this.actHitBox = actHitBox; } public ArrayList getPassThrowHitBox() { return passThrowHitBox; } public void setPassThrowHitBox(ArrayList passThrowHitBox) { this.passThrowHitBox = passThrowHitBox; } public ArrayList getActThrowHitBox() { return actThrowHitBox; } public void setActThrowHitBox(ArrayList actThrowHitBox) { this.actThrowHitBox = actThrowHitBox; } public Push_HitBox getPushHitBox() { return pushHitBox; } public void setPushHitBox(Push_HitBox pushHitBox) { this.pushHitBox = pushHitBox; } public boolean islastFrameOfHit() { return lastFrameOfHit; } public void setLastFrameOfHit(boolean lastFrameOfHit) { 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();} for(Active_HitBox p: this.actHitBox) {p.reverseHorizontally();} 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 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.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]); } /** * sets the coordinates on the spritesheet for the texture for that frame * @param x coordinate of the lef tside * @param y coordonate of the top * @param sizeH horizontal size of the sprite * @param sizeV horizontal size of the sprite */ public void setSpriteWrap(int x, int y, int sizeH, int sizeV) { this.sprite[0] = x; this.sprite[1] = y; this.sprite[2] = sizeH; this.sprite[3] = sizeV; } public int[] getSprite() { return sprite; } }