From c9c6148b99802f1edad798527b3ba96b18ab8a52 Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Tue, 31 Jan 2023 23:22:20 +0100 Subject: [PATCH 1/8] Update and add GamePanel --- src/main/java/GamePanel.java | 2 ++ src/main/java/MenuPanel.java | 17 +++++++++++++++-- target/classes/Main.class | Bin 237 -> 0 bytes target/classes/java/build-project.sh | 1 + target/classes/main/java/build-project.sh | 1 + 5 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/main/java/GamePanel.java delete mode 100644 target/classes/Main.class create mode 100644 target/classes/java/build-project.sh create mode 100644 target/classes/main/java/build-project.sh diff --git a/src/main/java/GamePanel.java b/src/main/java/GamePanel.java new file mode 100644 index 0000000..3311fd3 --- /dev/null +++ b/src/main/java/GamePanel.java @@ -0,0 +1,2 @@ +public class GamePanel { +} diff --git a/src/main/java/MenuPanel.java b/src/main/java/MenuPanel.java index 0fa2ec8..d505047 100644 --- a/src/main/java/MenuPanel.java +++ b/src/main/java/MenuPanel.java @@ -1,2 +1,15 @@ -public class MenuPanel { -} +import javax.swing.*; +import java.awt.*; + +public class MenuPanel extends JPanel { + MenuPanel() { + this.addKeyListener(new MenuPanel.AL()); + this.setBackground(Color.BLACK); + this.setFocusable(true); + this.setPreferredSize(GamePanel.SCREEN); + } + + protected void paintComponent(Graphics g) { + super.paintComponent(g); + draw(g); + } \ No newline at end of file diff --git a/target/classes/Main.class b/target/classes/Main.class deleted file mode 100644 index bc70d746889bbe4f84b0f95b48728d844a6f6def..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 237 zcmXYrO%8%E5QSg)5kVB<4cw^wM5WEhtjFA`o!?f=lKFY-pO#d>(o;2p}Q%EU(M30K3J{u?7Ww30rI kf|eq6$wjRP?CBHiLBN1Vs@wW%kJN8#n{vNp15yLQ4|)wMRsaA1 diff --git a/target/classes/java/build-project.sh b/target/classes/java/build-project.sh new file mode 100644 index 0000000..9a9a4a3 --- /dev/null +++ b/target/classes/java/build-project.sh @@ -0,0 +1 @@ +#!/usr/bin/bash \ No newline at end of file diff --git a/target/classes/main/java/build-project.sh b/target/classes/main/java/build-project.sh new file mode 100644 index 0000000..9a9a4a3 --- /dev/null +++ b/target/classes/main/java/build-project.sh @@ -0,0 +1 @@ +#!/usr/bin/bash \ No newline at end of file From 17e6618a7c5c771be3311ce8cdc540f677fe7a6f Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Tue, 31 Jan 2023 23:39:55 +0100 Subject: [PATCH 2/8] Update add Graphics --- src/main/java/GamePanel.java | 3 ++- src/main/java/MenuPanel.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/GamePanel.java b/src/main/java/GamePanel.java index 3311fd3..6079a5e 100644 --- a/src/main/java/GamePanel.java +++ b/src/main/java/GamePanel.java @@ -1,2 +1,3 @@ +import java.awt.*; + public class GamePanel { -} diff --git a/src/main/java/MenuPanel.java b/src/main/java/MenuPanel.java index d505047..3d0d021 100644 --- a/src/main/java/MenuPanel.java +++ b/src/main/java/MenuPanel.java @@ -12,4 +12,14 @@ public class MenuPanel extends JPanel { protected void paintComponent(Graphics g) { super.paintComponent(g); draw(g); + } + public void draw(Graphics g) { + g.setColor(Color.WHITE); + g.setFont(new Font("Consolas", Font.BOLD, 70)); + g.drawString("GAME MENU", 330, 100); + g.setFont(new Font("Consolas", Font.BOLD, 30)); + g.drawString("Press 'ENTER' to start the game", 265, 200); + g.setFont(new Font("Consolas", Font.PLAIN, 10)); + g.drawString("Created by Hells Gamers", 450, 450); + } \ No newline at end of file From a2a83698e40176d31ae8afe5a68381221e1735d5 Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Tue, 31 Jan 2023 23:45:28 +0100 Subject: [PATCH 3/8] Update add KeyAdapter --- src/main/java/GameFrame.java | 2 ++ src/main/java/MenuPanel.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/main/java/GameFrame.java diff --git a/src/main/java/GameFrame.java b/src/main/java/GameFrame.java new file mode 100644 index 0000000..91d7414 --- /dev/null +++ b/src/main/java/GameFrame.java @@ -0,0 +1,2 @@ +public class GameFrame { +} diff --git a/src/main/java/MenuPanel.java b/src/main/java/MenuPanel.java index 3d0d021..999a029 100644 --- a/src/main/java/MenuPanel.java +++ b/src/main/java/MenuPanel.java @@ -1,5 +1,7 @@ import javax.swing.*; import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; public class MenuPanel extends JPanel { MenuPanel() { @@ -22,4 +24,14 @@ public class MenuPanel extends JPanel { g.setFont(new Font("Consolas", Font.PLAIN, 10)); g.drawString("Created by Hells Gamers", 450, 450); - } \ No newline at end of file + } + public class AL extends KeyAdapter { + + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + GameFrame gameFrame = new GameFrame(); + } + + } + } +} \ No newline at end of file From 34a4eeaf32382c77cdc823089014a16e4958defd Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Tue, 31 Jan 2023 23:57:09 +0100 Subject: [PATCH 4/8] update GameFrame --- .idea/hellsgamers.iml | 4 ++-- src/main/java/GameFrame.java | 19 ++++++++++++++++++- src/main/java/build-project.sh | 2 +- target/classes/java/build-project.sh | 1 - target/classes/main/java/build-project.sh | 1 - 5 files changed, 21 insertions(+), 6 deletions(-) delete mode 100644 target/classes/java/build-project.sh delete mode 100644 target/classes/main/java/build-project.sh diff --git a/.idea/hellsgamers.iml b/.idea/hellsgamers.iml index db49080..c500079 100644 --- a/.idea/hellsgamers.iml +++ b/.idea/hellsgamers.iml @@ -6,8 +6,8 @@ - - + + diff --git a/src/main/java/GameFrame.java b/src/main/java/GameFrame.java index 91d7414..b6813fb 100644 --- a/src/main/java/GameFrame.java +++ b/src/main/java/GameFrame.java @@ -1,2 +1,19 @@ -public class GameFrame { +import javax.swing.*; +import java.awt.*; + +public class GameFrame extends JFrame { + GamePanel panel; + GameFrame(){ + panel = new GamePanel(); + this.add(panel); + this.setTitle("2D Ping-Pong"); + this.setResizable(false); + this.setBackground(new Color(31,78,47)); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + this.pack(); + this.setVisible(true); + this.setLocationRelativeTo(null); + + } + } diff --git a/src/main/java/build-project.sh b/src/main/java/build-project.sh index 9a9a4a3..cc1f786 100644 --- a/src/main/java/build-project.sh +++ b/src/main/java/build-project.sh @@ -1 +1 @@ -#!/usr/bin/bash \ No newline at end of file +#!/bin/bash \ No newline at end of file diff --git a/target/classes/java/build-project.sh b/target/classes/java/build-project.sh deleted file mode 100644 index 9a9a4a3..0000000 --- a/target/classes/java/build-project.sh +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/bash \ No newline at end of file diff --git a/target/classes/main/java/build-project.sh b/target/classes/main/java/build-project.sh deleted file mode 100644 index 9a9a4a3..0000000 --- a/target/classes/main/java/build-project.sh +++ /dev/null @@ -1 +0,0 @@ -#!/usr/bin/bash \ No newline at end of file From d9a892aae48c87b646b60e4af160f37fa06c035c Mon Sep 17 00:00:00 2001 From: Berkan Sarp Date: Wed, 1 Feb 2023 01:12:07 +0100 Subject: [PATCH 5/8] update GamePanel --- src/main/java/GamePanel.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/GamePanel.java b/src/main/java/GamePanel.java index 6079a5e..7e982fb 100644 --- a/src/main/java/GamePanel.java +++ b/src/main/java/GamePanel.java @@ -1,3 +1,11 @@ +import javax.swing.*; import java.awt.*; -public class GamePanel { +public class GamePanel extends JPanel implements Runnable { + static final int FRAME_WIDTH = 1000; + static final int FRAME_HEIGHT = (int) (FRAME_WIDTH * 0.5); + static final int BALL_DIAMETER = 26; + static final int PADDLE_WIDTH = 25; + static final int PADDLE_HEIGHT = 100; + static final Dimension SCREEN = new Dimension(FRAME_WIDTH, FRAME_HEIGHT); +} From b2e6ffb62c57f00a00bdeb7090b008dab6952052 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Wed, 1 Feb 2023 01:40:33 +0100 Subject: [PATCH 6/8] add Ball class --- README.md | 1 - src/main/java/Ball.java | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/main/java/Ball.java diff --git a/README.md b/README.md index 2a78ee8..6f03192 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,3 @@ Pong Game developed by Eren Esen, Berkan Sarp, Justin Senn, Brice Tchoumi Pong game is a two-player table tennis-themed console game. The game involves two paddles and a moving ball. The players have to move paddles in an upwards or downwards direction and save the ball from getting hit onto the wall. If the ball hits the wall then it’s a score for another player. The game ends at 20 Points. - diff --git a/src/main/java/Ball.java b/src/main/java/Ball.java new file mode 100644 index 0000000..f1f843c --- /dev/null +++ b/src/main/java/Ball.java @@ -0,0 +1,2 @@ +public class Ball { +} From 14a6219a8e1ab8f8323af06a85a8b2ffc7904a91 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Wed, 1 Feb 2023 01:52:05 +0100 Subject: [PATCH 7/8] add Paddle class --- src/main/java/Paddle.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/java/Paddle.java diff --git a/src/main/java/Paddle.java b/src/main/java/Paddle.java new file mode 100644 index 0000000..942d2bd --- /dev/null +++ b/src/main/java/Paddle.java @@ -0,0 +1,2 @@ +public class Paddle { +} From 3558211bd75fa856f3c2b42d293440130386e560 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Wed, 1 Feb 2023 01:53:04 +0100 Subject: [PATCH 8/8] add score class --- src/main/java/Score.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/java/Score.java diff --git a/src/main/java/Score.java b/src/main/java/Score.java new file mode 100644 index 0000000..e188430 --- /dev/null +++ b/src/main/java/Score.java @@ -0,0 +1,2 @@ +public class Score { +}