Première implémentation des pushBox
This commit is contained in:
parent
0a34a66a5d
commit
7f2a4800c6
@ -392,13 +392,13 @@ public class match {
|
|||||||
|
|
||||||
//Update of the current frame of each character
|
//Update of the current frame of each character
|
||||||
case 22:
|
case 22:
|
||||||
|
|
||||||
if(p1.getCurrentframe().islastFrameOfHit()) {
|
if(p1.getCurrentframe().islastFrameOfHit()) {
|
||||||
p1.removeFirstAttackPart();
|
p1.removeFirstAttackPart();
|
||||||
}
|
}
|
||||||
if(p2.getCurrentframe().islastFrameOfHit()) {
|
if(p2.getCurrentframe().islastFrameOfHit()) {
|
||||||
p2.removeFirstAttackPart();
|
p2.removeFirstAttackPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
nextFrame(p1,inputsP1);
|
nextFrame(p1,inputsP1);
|
||||||
nextFrame(p2,inputsP2);
|
nextFrame(p2,inputsP2);
|
||||||
|
|
||||||
@ -406,6 +406,8 @@ public class match {
|
|||||||
updatePos(p1,p1LooksRight);
|
updatePos(p1,p1LooksRight);
|
||||||
updatePos(p2,!p1LooksRight);
|
updatePos(p2,!p1LooksRight);
|
||||||
|
|
||||||
|
pushBox();
|
||||||
|
|
||||||
if(p1LooksRight) {
|
if(p1LooksRight) {
|
||||||
|
|
||||||
f = p1.getCurrentframe();
|
f = p1.getCurrentframe();
|
||||||
@ -633,6 +635,7 @@ public class match {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a character getting hit by an attack part.
|
* Handles a character getting hit by an attack part.
|
||||||
* @param c the character that's getting hit
|
* @param c the character that's getting hit
|
||||||
@ -736,6 +739,27 @@ public class match {
|
|||||||
else {c.setPos((int)(c.getPosX()-c.getCurrentframe().getMove_x()),(int)(c.getPosY()+c.getCurrentframe().getMove_y()));}
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
HITBOX DEBUG METHOD
|
HITBOX DEBUG METHOD
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user