diff --git a/bin/Ball.class b/bin/Ball.class index 9870a02..23e768a 100644 Binary files a/bin/Ball.class and b/bin/Ball.class differ diff --git a/bin/Game.class b/bin/Game.class index e9d001d..63fe36b 100644 Binary files a/bin/Game.class and b/bin/Game.class differ diff --git a/src/Ball.java b/src/Ball.java index 232ed10..d93972c 100644 --- a/src/Ball.java +++ b/src/Ball.java @@ -21,10 +21,10 @@ public class Ball extends JFrame implements KeyListener { public boolean rightUp; public boolean rightDown; - private boolean ballUp; - private boolean ballDown; - private boolean ballRight; - private boolean ballLeft; + public boolean ballUp; + public boolean ballDown; + public boolean ballRight; + public boolean ballLeft; Random rand; diff --git a/src/Game.java b/src/Game.java index ba98222..4c84db3 100644 --- a/src/Game.java +++ b/src/Game.java @@ -1,4 +1,4 @@ - +// 120 public class Game { Ball ball; @@ -16,14 +16,14 @@ public class Game { leftPlayer = new Player(); rightPlayer = new Player(); - + ball = new Ball(); ball.setSize(ball.xSize, ball.ySize); leftPlayer.setSize(0, leftPlayer.ySize); leftPlayer.setTitle("left Player"); - + rightPlayer.setSize(0, rightPlayer.ySize); rightPlayer.setTitle("right Player"); @@ -42,6 +42,15 @@ public class Game { ball.setLocation(ball.getPos('x', dt), ball.getPos('y', dt)); + if (ball.getPos('x', 0) < 0 || ball.getPos('x', 0) > 1785) { + ball.ballLeft = !ball.ballLeft; + ball.ballRight = !ball.ballRight; + } + if(ball.getPos('y', 0) < 0 || ball.getPos('y', 0) > 950) { + ball.ballUp = !ball.ballUp; + ball.ballDown = !ball.ballDown; + } + // ball.leftPlayer.setLocation(10, 700); // ball.xPos++;