From 40701ac566b0bdd7ec3b8078fd5b2ea26dda94ea Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:15:48 +0100 Subject: [PATCH 01/12] update --- src/main/java/BattleShip/GridGUI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 7756d31..155bfee 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -1,5 +1,8 @@ package BattleShip; +import javax.swing.*; +import javax.swing.border.Border; +import java.awt.*; import java.util.ArrayList; import java.util.Random; @@ -11,6 +14,10 @@ public class GridGUI { int numOfGuesses = 0; int rows; int columns; + boolean clicked = false; + boolean endGame = false; + Color darkRed = new Color(100, 80, 0); + Border loweredBevel = BorderFactory.createLoweredBevelBorder(); Ship destroyer = new Ship(2, "destroyer"); Ship cruiser = new Ship(3, "cruiser"); From e9510b0b95121129012c4a1c207b9303e54bff1e Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:17:53 +0100 Subject: [PATCH 02/12] refactoring: color change --- src/main/java/BattleShip/GridGUI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 155bfee..425a0bc 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -16,7 +16,7 @@ public class GridGUI { int columns; boolean clicked = false; boolean endGame = false; - Color darkRed = new Color(100, 80, 0); + Color darkRed = new Color(100, 0, 0); Border loweredBevel = BorderFactory.createLoweredBevelBorder(); Ship destroyer = new Ship(2, "destroyer"); From cf64f311ce329cfb1abddb011f91e0a290988786 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:21:47 +0100 Subject: [PATCH 03/12] update --- src/main/java/BattleShip/GridGUI.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 425a0bc..26550b1 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -3,6 +3,8 @@ package BattleShip; import javax.swing.*; import javax.swing.border.Border; import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Random; @@ -70,4 +72,9 @@ public class GridGUI { } } } + public class MyCellListener implements ActionListener { + public void actionPerformed(ActionEvent a) { + + } + } } \ No newline at end of file From e708788bcfef2a3d49e29cccf94c38b86b52f580 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:23:31 +0100 Subject: [PATCH 04/12] update --- src/main/java/BattleShip/GridGUI.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 26550b1..cf58c54 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -74,7 +74,13 @@ public class GridGUI { } public class MyCellListener implements ActionListener { public void actionPerformed(ActionEvent a) { - + if(!clicked) { + BSButton cell = (BSButton) a.getSource(); + Ship s = cell.getCellContents(); + boolean killed = false; + numOfGuesses++; + boolean gameOver = true; + } } } } \ No newline at end of file From 399b0c82f127cc3bf1fb3aaa798ca7b3b0b3c300 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:27:39 +0100 Subject: [PATCH 05/12] update --- src/main/java/BattleShip/GridGUI.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index cf58c54..b1b4a38 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -14,6 +14,7 @@ public class GridGUI { ArrayList allShips = new ArrayList(); int[] testLocations; int numOfGuesses = 0; + String text = ""; int rows; int columns; boolean clicked = false; @@ -80,6 +81,30 @@ public class GridGUI { boolean killed = false; numOfGuesses++; boolean gameOver = true; + cell.setEnabled(false); + cell.setBorder(loweredBevel); + + if(s == null) { + //Mark cell as missed. + text = "You missed. Other player's turn..."; + cell.setBackground(Color.lightGray); + } else { + killed = s.counter(); + if(killed) { + //Mark all of the ship's cells as killed. + text = "You sunk the " + s.getName() + "! Other player's turn..."; + for(BSButton bu : buttons) { + if(bu.getCellContents() == s) { + bu.setBackground(darkRed); + } + } + } else { + //Mark cell as hit. + text = "You got a hit. Other player's turn..."; + cell.setBackground(Color.red); + } + } + } } } From 2312ee54d4bdf1cbef74fb52f9213b2b99681d6a Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:30:35 +0100 Subject: [PATCH 06/12] update --- src/main/java/BattleShip/GridGUI.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index b1b4a38..d94c26a 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -104,7 +104,11 @@ public class GridGUI { cell.setBackground(Color.red); } } - + for(Ship sh : allShips) { + if(!sh.isKilled()) { + gameOver = false; + } + } } } } From 511bfc72f45aa855676c2266f25993d89fce1f75 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:32:46 +0100 Subject: [PATCH 07/12] update --- src/main/java/BattleShip/GridGUI.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index d94c26a..158f734 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -109,7 +109,15 @@ public class GridGUI { gameOver = false; } } + if(gameOver) { + text = "You win! You took " + numOfGuesses + " guesses."; + endGame = true; + } + + clicked = true; } } } -} \ No newline at end of file +} + + From 7152084ac6ed16a3b51732a1b76b12955f969ea8 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:47:11 +0100 Subject: [PATCH 08/12] update --- src/main/java/BattleShip/GridGUI.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 158f734..f7023f5 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -73,6 +73,8 @@ public class GridGUI { } } } + public boolean getClicked() {return clicked;} + public class MyCellListener implements ActionListener { public void actionPerformed(ActionEvent a) { if(!clicked) { From 4f5368ed0e71868fcbc086cbf0a4ed37eb21e4a9 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:48:57 +0100 Subject: [PATCH 09/12] update --- src/main/java/BattleShip/GridGUI.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index f7023f5..45401c3 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -74,7 +74,9 @@ public class GridGUI { } } public boolean getClicked() {return clicked;} - + public void setClicked() { + clicked = false; + } public class MyCellListener implements ActionListener { public void actionPerformed(ActionEvent a) { if(!clicked) { From 4123340fdc06863ab6dad7d3dba48bfb87cd7ba0 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:50:06 +0100 Subject: [PATCH 10/12] update --- src/main/java/BattleShip/GridGUI.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 45401c3..9b8c21a 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -77,6 +77,9 @@ public class GridGUI { public void setClicked() { clicked = false; } + public boolean getEndGame() { + return endGame; + } public class MyCellListener implements ActionListener { public void actionPerformed(ActionEvent a) { if(!clicked) { From bc5ef191b585d44bd19d6b69db9a76ba461a7774 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:51:27 +0100 Subject: [PATCH 11/12] update --- src/main/java/BattleShip/GridGUI.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/BattleShip/GridGUI.java b/src/main/java/BattleShip/GridGUI.java index 9b8c21a..5a9b32a 100644 --- a/src/main/java/BattleShip/GridGUI.java +++ b/src/main/java/BattleShip/GridGUI.java @@ -80,6 +80,11 @@ public class GridGUI { public boolean getEndGame() { return endGame; } + public void setEndGame() { + for(JButton j : buttons){ + j.setEnabled(false); + } + } public class MyCellListener implements ActionListener { public void actionPerformed(ActionEvent a) { if(!clicked) { From 03356df8d2fa3c38c80c7daa98d6ecc966f53f56 Mon Sep 17 00:00:00 2001 From: fdai4581 Date: Tue, 7 Feb 2023 21:54:35 +0100 Subject: [PATCH 12/12] update --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f03192..b3a5105 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ # HellsGamers -Pong Game developed by Eren Esen, Berkan Sarp, Justin Senn, Brice Tchoumi +"3-Games" 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. + +Battleship is a strategy type guessing game for two players. It is played on ruled grids on which each +player's fleet of warships are marked. The locations of the fleets are concealed from the other player. Players +alternate turns calling "shots" at the other player's ships, and the objective of the game is to destroy the +opposing player's fleet. + +Snake is an action video game in which the player maneuvers the end of a growing snake, often represented as a snake. +The objective of the game is to pick up the randomly appearing "apples" that are offered as food. As the snake grows +with each bite, maneuvering becomes increasingly difficult as the playing field becomes more crowded. You lose as soon +as you collide with yourself. \ No newline at end of file