CoolFace
Apppublic

diabolic6045/chess-vibe

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
App README

3D Chess Game

A multiplayer 3D chess game built with Three.js, Socket.IO, and Express.js. Play chess with friends in a beautiful 3D environment.

Features

  • Real-time multiplayer chess with 3D graphics
  • Create or join games with unique game codes
  • Full chess rule implementation including special moves (castling, en passant, promotion)
  • Chat functionality for in-game communication
  • Draw offers and resignation options
  • Responsive design that works on desktop and mobile
  • Secure communication with XSS protection and CSRF prevention
  • Fallback 2D board for browsers without WebGL support

Technologies Used

  • Frontend:
  • Three.js for 3D rendering
  • Socket.IO client for real-time communication
  • Vanilla JavaScript for game logic
  • CSS3 for styling
  • Backend:
  • Node.js with Express.js
  • Socket.IO for WebSocket communication
  • In-memory game state management

Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm (v6 or higher)

Installation

  1. 1.Clone the repository:
   git clone https://github.com/yourusername/3d-chess-game.git
   cd 3d-chess-game
  1. 1.Install dependencies:
   npm install
  1. 1.Start the server:
   npm start

Or use the debug mode for more detailed logs:

   start-debug.bat
  1. 1.Open your browser and navigate to:
   http://localhost:3000

How to Play

  1. 1.Create a Game:
  2. 2.Enter your name
  3. 3.Click "Create New Game"
  4. 4.Share the generated game code with your opponent
  1. 1.Join a Game:
  2. 2.Enter your name
  3. 3.Click "Join Game"
  4. 4.Enter the game code provided by the game creator
  5. 5.Click "Join"
  1. 1.Playing the Game:
  2. 2.White moves first
  3. 3.Click on a piece to select it
  4. 4.Valid moves will be highlighted
  5. 5.Click on a highlighted square to move
  6. 6.Use the chat to communicate with your opponent
  7. 7.Offer a draw or resign if needed

Troubleshooting

If you encounter any issues:

  1. 1.Connection Problems:
  2. 2.Make sure the server is running
  3. 3.Check your browser console for error messages
  4. 4.Try using the debug mode: start-debug.bat
  1. 1.3D Rendering Issues:
  2. 2.The game will automatically fall back to a 2D board if your browser doesn't support WebGL
  3. 3.Make sure your browser is up to date
  4. 4.Check if WebGL is enabled in your browser settings
  1. 1.Game Not Progressing:
  2. 2.Check the server console for any error messages
  3. 3.Make sure both players have joined the game
  4. 4.Try refreshing the page and rejoining the game

Game Rules

The game follows standard chess rules:

  • Each piece moves according to its traditional movement pattern
  • Special moves like castling, en passant, and pawn promotion are supported
  • Check, checkmate, and stalemate are detected automatically
  • The game ends when a player is checkmated, resigns, or when a draw occurs

Security Features

  • XSS protection for chat messages
  • CSRF protection for API requests
  • Clickjacking prevention
  • WebGL support detection
  • Secure game code generation
  • Input validation and sanitization

License

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

Acknowledgments