|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|