Battleship Game is a two-player, turn-based strategy game implemented in Node.js. Players place ships on an 8x8 grid and take turns guessing the opponent’s ship locations until one fleet is completely sunk, demonstrating core object-oriented programming principles in a fun, interactive console-based format.
-
Make sure Node.js is installed on your computer.
-
Download the file BattleshipGame.js to your local machine.
-
Open a terminal/command prompt and navigate to the directory containing the game file:
cd path/to/your/file -
Run the game using Node.js:
.load BattleshipGame.js
- Each player will be prompted to place their ships on the grid.
- Enter the starting coordinates for each ship (e.g., A1) and specify the orientation (horizontal/vertical) and direction (left/right/up/down).
- After both players place their ships, the game begins.
- Players take turns shooting at the opponent's grid by entering target coordinates.
- Hits are marked with 'X' and misses with 'O'.
- The game continues until all ships of one player are sunk.
- Carrier: 5
- Battleship: 4
- Cruiser: 3
- Submarine: 3
- Destroyer: 2