Ball - hitsPaddle update
This commit is contained in:
parent
8af4e653b2
commit
1a18e469ca
@ -105,14 +105,17 @@ public class Ball implements IBall {
|
||||
Position posBall = this.getPosition();
|
||||
|
||||
// test balls y position against paddles y values
|
||||
// paddles y values can be interpreted as a closed interval therefore if balls y position is in the interval, its true
|
||||
boolean testPaddleY = (
|
||||
(posBall.getY() <= posPaddle.getY()+paddle.getHeight() && posBall.getY() >= posPaddle.getY())
|
||||
|| (posBall.getY()+Constants.BALL_DIAMETER >= posPaddle.getY() && posBall.getY() <= posPaddle.getY()+paddle.getHeight())
|
||||
posPaddle.getY() <= posBall.getY() && posBall.getY() <= posPaddle.getY()+paddle.getHeight() ||
|
||||
posPaddle.getY() <= posBall.getY()+Constants.BALL_DIAMETER && posBall.getY()+Constants.BALL_DIAMETER <= posPaddle.getY()+paddle.getHeight()
|
||||
);
|
||||
|
||||
// test balls x position against paddles x values
|
||||
// paddles x values can be interpreted as a closed interval therefore if balls x position is in the interval, its true
|
||||
boolean testPaddleX = (
|
||||
posBall.getX() >= posPaddle.getX() && posBall.getX() <= posPaddle.getX()+paddle.getWidth()
|
||||
posPaddle.getX() <= posBall.getX() && posBall.getX() <= posPaddle.getX()+paddle.getWidth() ||
|
||||
posPaddle.getX() <= posBall.getX()+Constants.BALL_DIAMETER && posBall.getX()+Constants.BALL_DIAMETER <= posPaddle.getX()+paddle.getWidth()
|
||||
);
|
||||
|
||||
// if balls y position is in paddles y values, verify x position
|
||||
|
Loading…
x
Reference in New Issue
Block a user