Bataille Navale is a classic battleship game implemented in Java using Swing for the graphical user interface. This project allows two players to place their ships on a grid and take turns attacking each other's ships until one player wins.
- Two-player mode
- Graphical user interface with Swing
- Ship placement phase
- Attack phase with alternating turns
- Game pause and resume functionality
- Game log to track actions
- Java Development Kit (JDK) 8 or higher
- IntelliJ IDEA or any other Java IDE
- Clone the repository:
git clone https://github.com/yourusername/bataille-navale.git
- Open the project in your IDE.
- Navigate to the
srcdirectory. - Run the
Main.javafile to start the game.
- Ship Placement Phase:
- Player 1 places 5 ships on their grid.
- Player 2 places 5 ships on their grid.
- Attack Phase:
- Player 1 starts the attack phase.
- Players take turns to attack each other's grid.
- A pop-up message will indicate the next player's turn.
- Winning the Game:
- The game ends when all ships of one player are destroyed.
- A pop-up message will announce the winner.
Main.java: Entry point of the application.Game.java: Contains the main game logic, including ship placement and attack phases.createGridPanel(): Creates the grid panels for both players.handleButtonClick(): Handles button clicks for both ship placement and attacks.placeShip(): Manages the ship placement logic.attack(): Manages the attack logic and alternates turns between players.isGameOver(): Checks if the game is over.logAction(): Logs actions to the game log.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
- Java Swing for the graphical user interface.
- IntelliJ IDEA for the development environment.