A React + NodeJS implementation of the 2-player guessing game: Battleship. Features online multiplayer.
- Node.js (Tested on
v14.16.0
) - JavaScript-capable browser (Tested on Google Chrome) 2. JavaScript-capable browser (Tested on Google Chrome
v88.0.4324.150
)
-
To play the Battleship game, browse to
/client.html
of the host URL. (e.g: http://localhost:8000/client.html) -
Two grids will be presented:
- Ship Grid: This is where the player positions their ships for the opponent to guess and attack
- Guess Grid: This is where the player guesses and tries to attack the opponent's ships
-
Use the drop-down list to select the type of ship to place
Ship Name Length Color Aircraft Carrier 5 Red Battleship 4 Black Cruiser 3 Grey Destroyer 2 Yellow Submarine 1 Green -
Left-click to place the ship horizontally or right-click to place the ship vertically
-
If a ship needs repositioning, repeat steps 3 - 4
-
Once all ships have been placed, press Start Game
-
If an opponent is not available, please wait for an opponent
-
Once an opponent is available, use the guess grid to attack enemy positions, a cross represents a successful hit whereas a nought represents a miss
-
The first person to sink all ships wins
- Open a Terminal window in the directory containing
server.js
and run:
npm install
- Run the Battleship Server using the command:
npm start
- The server console window will display connection logs
- Server-side verification of ship placement and turns to prevent cheating
- Realtime grid update and message notification of every turn's outcome
- Multiple parallel game instances
- Player notified if opponent leaves