Welcome to Battleship Arcade, a stylish and colorful rendition of the classic naval combat game built entirely in Java Swing! Get ready to place your fleet and engage in strategic warfare against the AI in a grid-based showdown. โ๐ฅ
Battleship_Java_vSimple/
โโโ gui/ # ๐ฅ๏ธ GUI components and visual interface
โ โโโ BattleShipsGUI.java # ๐จ Main game window, handles user interaction
โโโ logic/ # ๐ง Core game logic and rules
โ โโโ GameController.java # ๐ฎ Game flow controller, manages turns and rules
โ โโโ Board.java # ๐บ๏ธ Board representation, stores ship positions & hits
โ โโโ ShipPlacer.java # ๐ข Logic for placing ships on the board
โโโ util/ # ๐ ๏ธ Utility classes and constants
โ โโโ Constants.java # ๐ Game constants (grid size, ship count, etc.)
โ
โโโ Main.java # ๐ฌ Entry point, starts the game
โโโ README.md # ๐ Project documentation.
โโโ LICENSE # ๐ MIT License.
The objective is simple: sink all 5 enemy ships before the computer sinks yours.
- You and the computer each have 5 ships.
- Each ship occupies 1 single cell on a 10ร10 grid.
- You must manually place your ships before the game begins.
Symbol | Meaning |
---|---|
โ |
Your ship |
x |
Hit (either yours or enemy's) |
โ |
Sunk ship |
โ |
Missed shot |
- ๐ก๏ธ Left Grid: Your ships.
- ๐ฏ Right Grid: Where you attack enemy positions.
- Colorful buttons and Unicode emojis enhance readability and fun!
Make sure you have Java JDK 8 or higher installed on your system.
If you have Git installed, open your terminal and type:
git clone https://github.com/andredisa/Battleship_Java_vSimple.git
cd Battleship_Java_vSimple
Open your terminal and navigate to the root project folder (
Battleship_Java_vSimple/
), then run:
javac -d out Main.java gui/*.java logic/*.java util/*.java
This command compiles all Java source files and places the generated .class files into the out/ directory.
java -cp out Main
Click 5 times on your grid (left side) to place your ships
(โ )
. You canโt overlap.
Once all ships are placed, the AI places its own ships randomly.
Click on the enemy grid (right side) to fire. The computer will respond with its move after yours.
๐ Win: Sink all 5 enemy ships first.
๐ Lose: The computer sinks all your ships first.
Once the game ends (win or lose), a message is shown and the app closes automatically.
- ๐จ Clean, emoji-rich GUI with color themes
- ๐ค Simple AI logic for ship placement and random firing
- ๐ฏ Visual feedback for each hit, miss, or sunken ship
- ๐งช Modular code structure for easy maintenance and expansion
Here are some exciting features planned to take the game to the next level:
- ๐ข Multi-cell Ships: Introduce ships spanning multiple cells (e.g., length 2 to 4) for added strategic depth.
- ๐ฎ Multiplayer Mode: Enable hotseat or LAN multiplayer battles to challenge friends.
- ๐ค AI Difficulty Levels: Implement adjustable difficulty settings to offer beginners and veterans a suitable challenge.
- ๐ Sound Effects & Animations: Add immersive audio cues and smooth animations for hits, misses, and ship sinking.
- ๐ Online Leaderboards: Track player scores and rankings globally.
- ๐ฅ๏ธ Improved UI/UX: Enhance interface responsiveness and accessibility options.
- ๐พ Save & Load Games: Allow players to save progress and resume battles later.
Feel free to fork or clone this repo!
Perfect for learning Java GUI programming and having fun! ๐
This project is open-source and free to use. Enjoy! ๐
If you find my work useful and would like to support me, you can buy me a coffee! Your support helps me keep creating and improving my projects. Thank you! ๐