217 lines
6.1 KiB
Java
217 lines
6.1 KiB
Java
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<Passive_HitBox> passHitBox;
|
|
private ArrayList<Active_HitBox> actHitBox;
|
|
private ArrayList<Passive_throw_HitBox> passThrowHitBox;
|
|
private ArrayList<Active_throw_Hitbox> 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<Passive_HitBox>());
|
|
this.setActHitBox(new ArrayList<Active_HitBox>());
|
|
this.setPassThrowHitBox(new ArrayList<Passive_throw_HitBox>());
|
|
this.setActThrowHitBox(new ArrayList<Active_throw_Hitbox>());
|
|
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<Passive_HitBox> passHitBox, ArrayList<Active_HitBox> actHitBox,
|
|
ArrayList<Passive_throw_HitBox> passThrowHitBox, ArrayList<Active_throw_Hitbox> 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<Passive_HitBox> passHitBox, ArrayList<Active_HitBox> actHitBox) {
|
|
this.setMove_y(move_y);
|
|
this.setMove_x(move_x);
|
|
this.setPassHitBox(passHitBox);
|
|
this.setActHitBox(actHitBox);
|
|
this.setPassThrowHitBox(new ArrayList<Passive_throw_HitBox>());
|
|
this.setActThrowHitBox(new ArrayList<Active_throw_Hitbox>());
|
|
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<Passive_HitBox> getPassHitBox() {
|
|
return passHitBox;
|
|
}
|
|
|
|
public void setPassHitBox(ArrayList<Passive_HitBox> passHitBox) {
|
|
this.passHitBox = passHitBox;
|
|
}
|
|
|
|
public ArrayList<Active_HitBox> getActHitBox() {
|
|
return actHitBox;
|
|
}
|
|
|
|
public void setActHitBox(ArrayList<Active_HitBox> actHitBox) {
|
|
this.actHitBox = actHitBox;
|
|
}
|
|
|
|
public ArrayList<Passive_throw_HitBox> getPassThrowHitBox() {
|
|
return passThrowHitBox;
|
|
}
|
|
|
|
public void setPassThrowHitBox(ArrayList<Passive_throw_HitBox> passThrowHitBox) {
|
|
this.passThrowHitBox = passThrowHitBox;
|
|
}
|
|
|
|
public ArrayList<Active_throw_Hitbox> getActThrowHitBox() {
|
|
return actThrowHitBox;
|
|
}
|
|
|
|
public void setActThrowHitBox(ArrayList<Active_throw_Hitbox> 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;
|
|
}
|
|
}
|