Hit Handling. Unfinished.
This commit is contained in:
@ -3,12 +3,17 @@ package gameplay.match;
|
||||
import engine.input.Button;
|
||||
import engine.input.GamepadInput;
|
||||
import gameplay.actions.Attack;
|
||||
import gameplay.actions.attackPart;
|
||||
import gameplay.entities.Status;
|
||||
import gameplay.hitboxes.Active_HitBox;
|
||||
import gameplay.hitboxes.Passive_HitBox;
|
||||
import gameplay.input.InputBuffer;
|
||||
import gameplay.entities.Character;
|
||||
import gameplay.input.Inputs;
|
||||
import gameplay.input.ButtonIG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
|
||||
/**
|
||||
@ -25,7 +30,6 @@ public class match {
|
||||
|
||||
private int timer;
|
||||
private InputBuffer inputsP1, inputsP2;
|
||||
private int hpP1, hpP2;
|
||||
private int roundsWonP1, roundsWonP2;
|
||||
private Character p1, p2; //characters of player 1 and 2
|
||||
|
||||
@ -45,8 +49,6 @@ public class match {
|
||||
this.inputsP2 = new InputBuffer(inputBufferSize);
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.hpP1 = p1.getMaxHP();
|
||||
this.hpP2 = p2.getMaxHP();
|
||||
this.roundsWonP1 = 0;
|
||||
this.roundsWonP2 = 0;
|
||||
}
|
||||
@ -58,8 +60,6 @@ public class match {
|
||||
this.timer = 99;
|
||||
this.inputsP1 = new InputBuffer(inputBufferSize);
|
||||
this.inputsP2 = new InputBuffer(inputBufferSize);
|
||||
this.hpP1 = p1.getMaxHP();
|
||||
this.hpP2 = p2.getMaxHP();
|
||||
this.p1.setPos(-500, 250); //TODO : change to better values if needed
|
||||
this.p2.setPos(500, 250); //TODO : change to better values if needed
|
||||
}
|
||||
@ -174,9 +174,9 @@ public class match {
|
||||
|
||||
//checks if one or both of the chars are out of health
|
||||
case 10:
|
||||
if(this.hpP1 <= 0 && hpP2 <= 0) { ac(11);}
|
||||
else if(this.hpP1 <= 0) { ac(12);}
|
||||
else if(this.hpP2 <= 0) { ac(13);}
|
||||
if(p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) { ac(11);}
|
||||
else if(p1.getCurrentHP() <= 0) { ac(12);}
|
||||
else if(p2.getCurrentHP() <= 0) { ac(13);}
|
||||
else { ac(20);}
|
||||
break;
|
||||
|
||||
@ -207,6 +207,14 @@ public class match {
|
||||
inputsP2.recordInputsFromGamepad(gamepad2, p2.getPosX() <= p1.getPosX());
|
||||
handleInputs(p1, inputsP1);
|
||||
handleInputs(p2, inputsP2);
|
||||
ac(21);
|
||||
break;
|
||||
|
||||
//start of the handling of hitboxes
|
||||
case 21:
|
||||
handleThrows();
|
||||
handleHits(p1,p2,inputsP2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -235,6 +243,7 @@ public class match {
|
||||
if(attackIsPossible) {
|
||||
c.clearNextFrames();
|
||||
c.addNextFramesList(atk.getFrame());
|
||||
c.setAttackPartsArray(atk.getParts());
|
||||
actionSet = true;
|
||||
}
|
||||
atkCount++;
|
||||
@ -285,4 +294,42 @@ public class match {
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void handleThrows() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* handles the if the first character hits the second one
|
||||
* @param p1 the character whose hits to handle
|
||||
* @param p2 the character who is or isn't hit
|
||||
* @param inputsP2 the inputs of the player 2, used to see if they're guarding
|
||||
*/
|
||||
private static void handleHits(Character p1, Character p2, InputBuffer inputsP2) {
|
||||
ArrayList<Active_HitBox> activeP1 = new ArrayList<Active_HitBox>(p1.getCurrentframe().getActHitBox());
|
||||
ArrayList<Passive_HitBox> passiveP2 = new ArrayList<Passive_HitBox>(p2.getCurrentframe().getPassHitBox());
|
||||
ArrayList<attackPart> aP = new ArrayList<attackPart>(p1.getNextAttackParts());
|
||||
attackPart hit = new attackPart(aP.get(0).getFrames());
|
||||
hit.clone(aP.get(0));
|
||||
for(Active_HitBox aH : activeP1) {
|
||||
for(Passive_HitBox pH : passiveP2) {
|
||||
if(!hit.hasHit()){
|
||||
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||
boolean touchH = (p1LooksRight && (aH.getPosX()+p1.getPosX()+ aH.getSize_x() > pH.getPosX()+p2.getPosX()+pH.getSize_x())
|
||||
&& (aH.getPosX() < pH.getPosX()))
|
||||
|| (!p1LooksRight && (aH.getPosX()+p1.getPosX()+ aH.getSize_x() < pH.getPosX()+p2.getPosX()+pH.getSize_x())
|
||||
&& (aH.getPosX() > pH.getPosX()));
|
||||
|
||||
boolean touchV = (aH.getPosY() - aH.getSize_y() < pH.getPosY()) && (aH.getPosY() > pH.getPosY() - pH.getSize_y());
|
||||
if(touchH && touchV) {
|
||||
if(p2.)
|
||||
hit.setHasHit(true);
|
||||
aP.set(0,hit);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user