Browse Source

refactoring:

main
fdai4616 2 years ago
parent
commit
26493c3a9f
  1. 5
      src/main/java/PingPong/GamePanel.java

5
src/main/java/PingPong/GamePanel.java

@ -4,7 +4,6 @@ import javax.swing.*;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.util.Random;
public class GamePanel extends JPanel implements Runnable { public class GamePanel extends JPanel implements Runnable {
@ -27,7 +26,7 @@ public class GamePanel extends JPanel implements Runnable {
public GamePanel() { public GamePanel() {
newPeddle();
newPaddle();
newBall(); newBall();
score = new Score(FRAME_WIDTH, FRAME_HEIGHT); score = new Score(FRAME_WIDTH, FRAME_HEIGHT);
collisionChecker = new CollisionChecker(); collisionChecker = new CollisionChecker();
@ -76,7 +75,7 @@ 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 void newPeddle() {
public void newPaddle() {
paddle_1 = new Paddle(0, (FRAME_HEIGHT/2)-(PADDLE_HEIGHT/2), PADDLE_WIDTH, PADDLE_HEIGHT, 1 ); paddle_1 = new Paddle(0, (FRAME_HEIGHT/2)-(PADDLE_HEIGHT/2), PADDLE_WIDTH, PADDLE_HEIGHT, 1 );
paddle_2 = new Paddle(FRAME_WIDTH-PADDLE_WIDTH, (FRAME_HEIGHT/2)-(PADDLE_HEIGHT/2), PADDLE_WIDTH, PADDLE_HEIGHT, 2 ); paddle_2 = new Paddle(FRAME_WIDTH-PADDLE_WIDTH, (FRAME_HEIGHT/2)-(PADDLE_HEIGHT/2), PADDLE_WIDTH, PADDLE_HEIGHT, 2 );
} }

Loading…
Cancel
Save