diff --git a/src/main/java/PingPong/GamePanel.java b/src/main/java/PingPong/GamePanel.java index c85e00c..384db1b 100644 --- a/src/main/java/PingPong/GamePanel.java +++ b/src/main/java/PingPong/GamePanel.java @@ -63,6 +63,14 @@ public class GamePanel extends JPanel implements Runnable { ball.setXDirection(-ball.xVelocity); ball.setYDirection(ball.yVelocity); } + if (paddle_1.y1 <= 0) + paddle_1.y1 = 0; + if (paddle_1.y1 >= (FRAME_HEIGHT-PADDLE_HEIGHT)) + paddle_1.y1 = FRAME_HEIGHT-PADDLE_HEIGHT; + if (paddle_2.y2 <= 0) + paddle_2.y2 = 0; + if (paddle_2.y2 >= (FRAME_HEIGHT-PADDLE_HEIGHT)) + paddle_2.y2 = FRAME_HEIGHT-PADDLE_HEIGHT; }