|
|
@ -2,6 +2,8 @@ package PingPong; |
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.util.Random; |
|
|
|
|
|
|
|
|
|
|
|
public class GamePanel extends JPanel implements Runnable { |
|
|
|
static final int FRAME_WIDTH = 1000; |
|
|
@ -11,14 +13,30 @@ public class GamePanel extends JPanel implements Runnable { |
|
|
|
static final int PADDLE_HEIGHT = 100; |
|
|
|
public static final Dimension SCREEN = new Dimension(FRAME_WIDTH, FRAME_HEIGHT); |
|
|
|
|
|
|
|
|
|
|
|
Ball ball; |
|
|
|
Paddle paddle_1; |
|
|
|
Paddle paddle_2; |
|
|
|
Score score; |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
public void draw(Graphics g) { |
|
|
|
score.draw(g); |
|
|
|
paddle_1.draw(g); |
|
|
|
paddle_2.draw(g); |
|
|
|
ball.draw(g); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void newBall() { |
|
|
|
|
|
|
|
ball = new Ball((FRAME_WIDTH/2)-(BALL_DIAMETER/2), ((FRAME_HEIGHT/2)-(BALL_DIAMETER/2)), BALL_DIAMETER, BALL_DIAMETER); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |