Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5e7e0e2f89
@ -381,6 +381,7 @@ public class match {
|
||||
case 21:
|
||||
try {
|
||||
handleThrows(p1, p2);
|
||||
handleThrows(p2,p1);
|
||||
} catch (IndexOutOfBoundsException e) {}
|
||||
try {
|
||||
handleHits(p1, p2, inputsP2);
|
||||
@ -391,13 +392,13 @@ public class match {
|
||||
|
||||
//Update of the current frame of each character
|
||||
case 22:
|
||||
|
||||
if(p1.getCurrentframe().islastFrameOfHit()) {
|
||||
p1.removeFirstAttackPart();
|
||||
}
|
||||
if(p2.getCurrentframe().islastFrameOfHit()) {
|
||||
p2.removeFirstAttackPart();
|
||||
}
|
||||
|
||||
nextFrame(p1,inputsP1);
|
||||
nextFrame(p2,inputsP2);
|
||||
|
||||
@ -405,6 +406,9 @@ public class match {
|
||||
updatePos(p1,p1LooksRight);
|
||||
updatePos(p2,!p1LooksRight);
|
||||
|
||||
pushBox();
|
||||
cameraPushBack();
|
||||
|
||||
if(p1LooksRight) {
|
||||
|
||||
f = p1.getCurrentframe();
|
||||
@ -584,7 +588,9 @@ public class match {
|
||||
|| (!p1LooksRight && (atH.getPosX()+p1.getPosX()+ atH.getSize_x() < ptH.getPosX()+p2.getPosX()+ptH.getSize_x())
|
||||
&& (atH.getPosX() > ptH.getPosX()));
|
||||
|
||||
boolean touchV = (atH.getPosY() - atH.getSize_y() < ptH.getPosY()) && (atH.getPosY() > ptH.getPosY() - ptH.getSize_y());
|
||||
|
||||
boolean touchV = (atH.getPosY()+p1.getPosY() - atH.getSize_y() < ptH.getPosY()+p2.getPosY()) && (atH.getPosY()+p1.getPosY() > ptH.getPosY()+p2.getPosY() - ptH.getSize_y());
|
||||
|
||||
if(touchH && touchV) {
|
||||
hit.setHasHit(true);
|
||||
tP.set(0,hit);
|
||||
@ -616,7 +622,9 @@ public class match {
|
||||
|| (!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());
|
||||
|
||||
boolean touchV = (aH.getPosY()+p1.getPosY() - aH.getSize_y() < pH.getPosY()+p2.getPosY()) && (aH.getPosY()+p1.getPosY() > pH.getPosY()+p2.getPosY() - pH.getSize_y());
|
||||
|
||||
if(touchH && touchV) {
|
||||
getHit(p2,hit,inputsP2.getLatestInputs());
|
||||
hit.setHasHit(true);
|
||||
@ -628,6 +636,7 @@ public class match {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles a character getting hit by an attack part.
|
||||
* @param c the character that's getting hit
|
||||
@ -731,6 +740,51 @@ public class match {
|
||||
else {c.setPos((int)(c.getPosX()-c.getCurrentframe().getMove_x()),(int)(c.getPosY()+c.getCurrentframe().getMove_y()));}
|
||||
}
|
||||
|
||||
private static void pushBox(){
|
||||
Push_HitBox phb1 = p1.getCurrentframe().getPushHitBox();
|
||||
Push_HitBox phb2 = p2.getCurrentframe().getPushHitBox();
|
||||
// Check if there is an intersection only on the x axis, if we push on the y axis character could get stuck in the air
|
||||
boolean lookRight = p1.getPosX() < p2.getPosX();
|
||||
float sizeIntersection = lookRight ? p1.getPosX() + phb1.getPosX() + phb1.getSize_x() - p2.getPosX() - phb2.getPosX()
|
||||
: p2.getPosX() + phb2.getPosX() + phb2.getSize_x() - p1.getPosX() - phb1.getPosX();
|
||||
boolean col = 0 < sizeIntersection;
|
||||
boolean colV = (phb1.getPosY() + p1.getPosY() - phb1.getSize_y() < phb2.getPosY() + p2.getPosY()) && (phb1.getPosY() + p1.getPosY() > phb2.getPosY() + p2.getPosY() - phb2.getSize_y());
|
||||
if (col && colV){
|
||||
if(lookRight){
|
||||
p1.setPos((int) (p1.getPosX() - sizeIntersection/2), p1.getPosY());
|
||||
p2.setPos((int) (p2.getPosX() + sizeIntersection/2), p2.getPosY());
|
||||
} else {
|
||||
p1.setPos((int) (p1.getPosX() + sizeIntersection/2), p1.getPosY());
|
||||
p2.setPos((int) (p2.getPosX() - sizeIntersection/2), p2.getPosY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static void cameraPushBack(){
|
||||
boolean lookRight = p1.getPosX() < p2.getPosX();
|
||||
Character left;
|
||||
Character right;
|
||||
ObjectGl rightObj;
|
||||
if (lookRight) {
|
||||
left = p1;
|
||||
right = p2;
|
||||
rightObj = objP2;
|
||||
} else {
|
||||
left = p2;
|
||||
right = p1;
|
||||
rightObj = objP1;
|
||||
}
|
||||
float leftOutOfView = left.getPosX() - (-engine.getViewXPos() - engine.getCamera().getDimension());
|
||||
float rightOutOfView = (right.getPosX() + rightObj.getWidth() * rightObj.getScalingFactor()) - (-engine.getViewXPos() + engine.getCamera().getDimension());
|
||||
if(leftOutOfView < 0 && rightOutOfView > 0){
|
||||
left.setPos((int) (left.getPosX() - leftOutOfView), left.getPosY());
|
||||
right.setPos((int) (right.getPosX() - rightOutOfView), right.getPosY());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
HITBOX DEBUG METHOD
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user