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:
- Clone the repository:
git clone https://github.com/Re-Dei-s-Organization/Battleship
- Install dependencies:
npm install
in two shells for backend and frontend - Configure Database: Update .env with your MongoDB connection details.
- Start the server:
npm start
- Run the application: In separate terminal windows, run
npm run client
twice to open the game interface for both players.
Playing the Game:
- Open the application URL (e.g.,
http://localhost:3000
) in two different browsers. - Enter a username and join a game or create a new one.
- Players take turns placing their ships on the board.
- Once ships are placed, players attack each other's boards by clicking on grid squares.
- 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.