Skip to content

Ofek-Carpassi/ChessJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChessJS

This is a very simple implementation of the classic "Chess" game.
It is written in JavaScript and uses the HTML5 canvas for rendering.

Features

  • Drag and drop functionality to move pieces instead of using onclick events.
  • Automatic detection of valid moves.
  • Automatic detection of when a player is in check.
  • Automatic detection of when a player has won.
  • Automatic detection of a draw by stalemate.

How to run

Just open the index.html file in your browser.

Code Structure

The games logic is implemented in the game.js file.
This file includes the initialization of the game board, the logic for moving and capturing pieces, and the logic for determining when a player has won.
The BuildBoard function is used to draw the board on the canvas.
The drag, allowDrop, and drop functions are used to implement the drag and drop functionality.
The checkWin function is used to determine when a player has won.

Future Improvements

  • Add multiplayer online functionality.
  • Add an AI to play against.
  • Add a scoring system.
  • Improve the UI.
  • Add options to save and load games.
  • Add move history and undo functionality.
  • Add animations for moving pieces.
  • Add sound effects.
  • Add a timer for each player's turn.
  • Add a tutorial for new players.
  • Add a points system for each piece.

Contributing

Feel free to contribute to this project.
Please open an issue if you have any suggestions or find any bugs.

License

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