Browse Source

update

main
fdai4616 2 years ago
parent
commit
b5f10c9c70
  1. 13
      src/main/java/PingPong/GamePanel.java
  2. 4
      src/main/java/PingPong/Paddle.java

13
src/main/java/PingPong/GamePanel.java

@ -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);
}
}

4
src/main/java/PingPong/Paddle.java

@ -1,8 +1,12 @@
package PingPong; package PingPong;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent;
public class Paddle { public class Paddle {
public void draw(Graphics g) { public void draw(Graphics g) {
} }
public void pressed(KeyEvent e) {
}
} }
Loading…
Cancel
Save