/Battleship

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Battleship: Online Two-Player Game with React, Node, Socket.io, and MongoDB

This project is a real-time, two-player Battleship game built with:

  • Frontend: React for building the user interface and handling player interactions.
  • Backend: Node.js for server-side logic and communication with the database.
  • Real-time Communication: Socket.io for real-time data exchange between players.
  • Database: MongoDB for storing game data and player information.

Features:

  • Two-player online game with real-time updates
  • Battleship game logic with ship placement and firing mechanics
  • User authentication and game status tracking
  • Visual representation of the game board and ships

Dependencies:

  • Node.js and npm package manager
  • React and React libraries (e.g., react-router-dom)
  • Socket.io
  • Mongoose (MongoDB Object Document Mapper)

Getting Started:

  1. Clone the repository: git clone https://github.com/Re-Dei-s-Organization/Battleship
  2. Install dependencies: npm install in two shells for backend and frontend
  3. Configure Database: Update .env with your MongoDB connection details.
  4. Start the server: npm start
  5. Run the application: In separate terminal windows, run npm run client twice to open the game interface for both players.

Playing the Game:

  1. Open the application URL (e.g., http://localhost:3000) in two different browsers.
  2. Enter a username and join a game or create a new one.
  3. Players take turns placing their ships on the board.
  4. Once ships are placed, players attack each other's boards by clicking on grid squares.
  5. The game continues until one player's ships are all sunk.

Note:

  • This project is a basic demonstration and can be extended with additional features like chat functionality, game history tracking, and improved user interface elements.
  • Refer to the code comments and documentation within the project for further details.

Contributing:

We welcome contributions to this project. Feel free to fork the repository and submit pull requests with your enhancements.

License:

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer:

This project is for educational purposes only and is not intended for commercial use.

Live Demo

https://battleship-io.onrender.com