Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 1.33 KB

File metadata and controls

30 lines (22 loc) · 1.33 KB

BattleshipGame-JavaScript

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.

How to Run

  1. Make sure Node.js is installed on your computer.

  2. Download the file BattleshipGame.js to your local machine.

  3. Open a terminal/command prompt and navigate to the directory containing the game file: cd path/to/your/file

  4. Run the game using Node.js: .load BattleshipGame.js

    image

Game Instructions

  1. Each player will be prompted to place their ships on the grid.
  2. Enter the starting coordinates for each ship (e.g., A1) and specify the orientation (horizontal/vertical) and direction (left/right/up/down).
  3. After both players place their ships, the game begins.
  4. Players take turns shooting at the opponent's grid by entering target coordinates.
  5. Hits are marked with 'X' and misses with 'O'.
  6. The game continues until all ships of one player are sunk.

Ship Sizes

  • Carrier: 5
  • Battleship: 4
  • Cruiser: 3
  • Submarine: 3
  • Destroyer: 2