1
0
Fork 0

BreakOut 5.1 - a)

This commit is contained in:
rxbn_ 2020-01-30 19:10:49 +01:00
parent b51c1c4f62
commit 5ea292bbae
1 changed files with 23 additions and 4 deletions

View File

@ -28,6 +28,11 @@ public class Ball implements IBall {
*/
private boolean hitsPaddle;
/**
* The balls lost state for upper and lower borders
*/
private boolean isLost;
/**
* The balls color with default component color
*/
@ -147,14 +152,12 @@ public class Ball implements IBall {
// reacts on top border
if (this.position.getY() <= 0) {
this.position.setY(0);
this.direction.setDy(-(this.direction.getDy()));
isLost = true;
}
// reacts on bottom border (+Diameter because of hitbox)
if (this.position.getY() >= Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER) {
this.position.setY(Constants.SCREEN_HEIGHT - Constants.BALL_DIAMETER);
this.direction.setDy(-(this.direction.getDy()));
isLost = true;
}
}
@ -369,4 +372,20 @@ public class Ball implements IBall {
}
/**
* The getter for balls lost state
* @return balls lost state
*/
public boolean isLost() {
return isLost;
}
/**
* The setter for balls lost state
* @param lost balls lost state
*/
public void setLost(boolean lost) {
isLost = lost;
}
}