CameraPushBack fonctionne 😎
This commit is contained in:
parent
ecc501729c
commit
773e72fabe
@ -406,6 +406,7 @@ public class match {
|
||||
updatePos(p2,!p1LooksRight);
|
||||
|
||||
pushBox();
|
||||
|
||||
cameraPushBack();
|
||||
|
||||
if(p1LooksRight) {
|
||||
@ -441,6 +442,7 @@ public class match {
|
||||
objP1.flipTextureWrapH();
|
||||
}
|
||||
|
||||
engine.cameraTracking();
|
||||
|
||||
// Debug Hitbox Management
|
||||
removeHitboxEngine();
|
||||
@ -464,8 +466,6 @@ public class match {
|
||||
healthBarP1Obj.setCurrent(p1.getCurrentHP()); healthBarP1Obj.setMax(p1.getMaxHP());
|
||||
healthBarP2Obj.setCurrent(p2.getCurrentHP()); healthBarP2Obj.setMax(p2.getMaxHP());
|
||||
timerUI.setText(timer + "");
|
||||
// Tracking update
|
||||
engine.cameraTracking();
|
||||
|
||||
timer = 99 - frameCount/60;
|
||||
|
||||
@ -753,6 +753,7 @@ public class match {
|
||||
}
|
||||
|
||||
private static void pushBox(){
|
||||
int push = 100;
|
||||
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
|
||||
@ -789,10 +790,19 @@ public class match {
|
||||
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){
|
||||
|
||||
boolean leftOOB = left.getPosX() < -engine.getViewXPos() - engine.getCamera().getDimension();
|
||||
boolean rightOOB = right.getPosX() + rightObj.getWidth() * rightObj.getScalingFactor() > -engine.getViewXPos() + engine.getCamera().getDimension();
|
||||
|
||||
if(leftOOB && rightOutOfView - leftOutOfView > 0){
|
||||
System.out.println("Left: " + leftOutOfView);
|
||||
left.setPos((int) (left.getPosX() - leftOutOfView), left.getPosY());
|
||||
}
|
||||
if(rightOOB && leftOutOfView + rightOutOfView < 0){
|
||||
System.out.println("Right: " + rightOutOfView);
|
||||
right.setPos((int) (right.getPosX() - rightOutOfView), right.getPosY());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user