Skip to content

๐Ÿšข Welcome to Battleship Arcade, a stylish and colorful rendition of the classic naval combat game built entirely in Java Swing!

License

Notifications You must be signed in to change notification settings

andredisa/Battleship_Java_vSimple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿšข Battleship Arcade โ€“ Java ๐ŸŽฎ

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. โš“๐Ÿ’ฅ


๐Ÿ“ท Screenshots ๐Ÿ“ท

Menu Screenshot Game Screenshot

๐Ÿ“ฆ Project Structure

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.

๐Ÿ•น๏ธ Gameplay

The objective is simple: sink all 5 enemy ships before the computer sinks yours.

๐Ÿ›ณ๏ธ Ship Details

  • 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.

๐Ÿงฉ Symbols Guide

Symbol Meaning
โ–  Your ship
x Hit (either yours or enemy's)
โ˜  Sunk ship
โ‰ˆ Missed shot

๐ŸŽจ Interface

  • ๐Ÿ›ก๏ธ Left Grid: Your ships.
  • ๐ŸŽฏ Right Grid: Where you attack enemy positions.
  • Colorful buttons and Unicode emojis enhance readability and fun!

๐Ÿš€ How to Run

โœ… Prerequisites

Make sure you have Java JDK 8 or higher installed on your system.

๐Ÿ“ฅ Clone the repository

If you have Git installed, open your terminal and type:

git clone https://github.com/andredisa/Battleship_Java_vSimple.git
cd Battleship_Java_vSimple

๐Ÿ”ง Compiling the Project

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.

โ–ถ๏ธ Launching the Game

java -cp out Main

๐Ÿง  How to Play

1๏ธโƒฃ Place Your Ships:

Click 5 times on your grid (left side) to place your ships (โ– ). You canโ€™t overlap.

2๏ธโƒฃ Start the Battle:

Once all ships are placed, the AI places its own ships randomly.

Take Turns:

Click on the enemy grid (right side) to fire. The computer will respond with its move after yours.

Win or Lose:

๐Ÿ† Win: Sink all 5 enemy ships first.

๐Ÿ’€ Lose: The computer sinks all your ships first.


๐Ÿงผ Reset / Exit

Once the game ends (win or lose), a message is shown and the app closes automatically.


๐Ÿ’ก Features

  • ๐ŸŽจ 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

๐Ÿ”„ Future Enhancements & Ideas

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.

๐ŸŽ‰ Try it Out!

Feel free to fork or clone this repo!
Perfect for learning Java GUI programming and having fun! ๐Ÿ˜„


๐Ÿ“ License

This project is open-source and free to use. Enjoy! ๐Ÿš€


โ˜• Support Me

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! ๐Ÿ˜Š

Buy Me A Coffee


Enjoy sinking ships! ๐ŸŒŠ๐Ÿ”ฅ If you like it, give it a โญ!

About

๐Ÿšข Welcome to Battleship Arcade, a stylish and colorful rendition of the classic naval combat game built entirely in Java Swing!

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages