|
@ -2,6 +2,8 @@ package PingPong; |
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
import javax.swing.*; |
|
|
import java.awt.*; |
|
|
import java.awt.*; |
|
|
|
|
|
import java.awt.event.KeyAdapter; |
|
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
import java.util.Random; |
|
|
import java.util.Random; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -21,9 +23,12 @@ public class GamePanel extends JPanel implements Runnable { |
|
|
Image image; |
|
|
Image image; |
|
|
Graphics graphics; |
|
|
Graphics graphics; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void run() { |
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
public void draw(Graphics g) { |
|
|
public void draw(Graphics g) { |
|
|
score.draw(g); |
|
|
score.draw(g); |
|
@ -44,6 +49,14 @@ public class GamePanel extends JPanel implements Runnable { |
|
|
ball = new Ball((FRAME_WIDTH/2)-(BALL_DIAMETER/2), ((FRAME_HEIGHT/2)-(BALL_DIAMETER/2)), BALL_DIAMETER, BALL_DIAMETER); |
|
|
ball = new Ball((FRAME_WIDTH/2)-(BALL_DIAMETER/2), ((FRAME_HEIGHT/2)-(BALL_DIAMETER/2)), BALL_DIAMETER, BALL_DIAMETER); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class AL extends KeyAdapter { |
|
|
|
|
|
|
|
|
|
|
|
public void keyPressed(KeyEvent e) { |
|
|
|
|
|
paddle_1.pressed(e); |
|
|
|
|
|
paddle_2.pressed(e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|