This is a simple implementation of the classic game Battleship programmed in Java using the Swing library for the graphical user interface.
- Run the
Principal.java
file to start the game. - A new window will be displayed to select the desired name and difficulty. Additionally, you will have the option to load a previous game.
- After clicking on "Empezar partida", you will be asked to place the ships by first selecting the desired direction. The ships will be placed in the order shown in the bottom left corner.
- Click on the opponent's board to select a position to attack.
- The game will indicate if your attack was a hit or a miss.
- The opponent will take its turn and attack your board.
- Continue taking turns until all ships on one side are sunk.
- The game will display the final result and allow you to play again, providing the option to save or load the desired game.
- The game supports single-player mode with two different difficulty options:
- Easy: The CPU will randomly shoot squares.
- Normal: The CPU will shoot around the hit squares..
- The game boards are displayed using a graphical user interface built with Swing.
- The game enforces valid moves and provides feedback on the outcome of each attack.
- The game keeps track of the score and displays the winner at the end of each round.
- The game implements game save/load functionality.
- Java Development Kit (JDK) 8 or higher.
- A Java IDE or command-line tools to compile and run the program.
- Clone the repository or download the source code.
- Create a new project in your preferred Java IDE.
- Copy the folder /src/tocadoHundido to your /src folder.
- Compile and run the
Principal.java
file to start the game. - Follow the on-screen instructions to play the game.