Browse Source

update

main
fdai4616 2 years ago
parent
commit
a68279763d
  1. 8
      src/main/java/PingPong/GamePanel.java

8
src/main/java/PingPong/GamePanel.java

@ -63,6 +63,14 @@ public class GamePanel extends JPanel implements Runnable {
ball.setXDirection(-ball.xVelocity); ball.setXDirection(-ball.xVelocity);
ball.setYDirection(ball.yVelocity); 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;
} }

Loading…
Cancel
Save