From 625f2a29ceb923fc0af25d3182effc0e7feeeea9 Mon Sep 17 00:00:00 2001 From: fdai4616 Date: Tue, 7 Feb 2023 22:49:13 +0100 Subject: [PATCH] update --- src/main/java/PingPong/GamePanel.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/PingPong/GamePanel.java b/src/main/java/PingPong/GamePanel.java index 3b982e5..8c6e88a 100644 --- a/src/main/java/PingPong/GamePanel.java +++ b/src/main/java/PingPong/GamePanel.java @@ -18,6 +18,8 @@ public class GamePanel extends JPanel implements Runnable { Paddle paddle_1; Paddle paddle_2; Score score; + Image image; + Graphics graphics; public void run() { @@ -30,6 +32,12 @@ public class GamePanel extends JPanel implements Runnable { ball.draw(g); } + public void paint(Graphics g) { + image = createImage(getWidth(), getHeight()); + graphics = image.getGraphics(); + draw(graphics); + g.drawImage(image, 0, 0, this); + } public void newBall() {