From a68279763df4550d3ae379b330af96a2a50379a3 Mon Sep 17 00:00:00 2001 From: fdai4616 Date: Wed, 8 Feb 2023 20:47:22 +0100 Subject: [PATCH] update --- src/main/java/PingPong/GamePanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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; }