A real-time chess game built with Node.js, Socket.io, and Chess.js. Play with friends in a simple, responsive interface and enjoy real-time updates on your chessboard.
- 🎮 Play chess with friends in real-time
- ⚔️ Validates moves using Chess.js (correct chess rules are enforced)
- 🔄 Automatically updates the board for all players
- 👀 Spectator mode for users who join once both players are already connected
- ♜ Flips the board for the black player
- Backend: Node.js, Express, Socket.io, Chess.js
- Frontend: HTML, CSS, JavaScript, Socket.io-client
- Views: EJS (Embedded JavaScript templates)
-
Clone the repository:
git clone https://github.com/your-username/chess-game.git cd chess-game
-
Install dependencies:
npm install
-
Run the server:
npm start
-
Open your browser and visit
http://localhost:3000
to play the game.
- Two players can play against each other.
- The first player to connect will be assigned the white pieces, and the second player will be assigned the black pieces.
- Any additional connections will result in spectator mode.
- Drag and drop pieces to make a move. Only valid moves are allowed.
- This chess game follows standard chess rules.
- Players take turns moving pieces.
- The game ends when there is a checkmate, stalemate, or draw.
chess-game/
│
├── public/ # Frontend assets (CSS, JS)
│ ├── main.js # Frontend logic
│ └── styles.css # Chessboard styling
│
├── views/ # EJS templates
│ └── index.ejs # Main game interface
│
├── app.js # Backend server and Socket.io logic
├── package.json # Node.js dependencies and scripts
├── README.md # Project documentation (this file)
└── .gitignore # Files to ignore in Git