Skip to content

Rayan581/Chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โ™Ÿ๏ธ Chess Game ๐Ÿงฉ

Yo, welcome to this epic Chess Game built with Python and Pygame! Itโ€™s a fully functional chess experience with slick visuals, sound effects, timers, and all the classic chess rules โ€” from castling to en passant to pawn promotions. Whether you're a chess grandmaster or just here for the vibes, this gameโ€™s got you covered. ๐Ÿ˜Ž


๐Ÿ”ฅ Features

  • โ™Ÿ๏ธ Classic Chess Gameplay โ€“ Full support for standard chess rules.
  • โฑ๏ธ 10-Minute Timers โ€“ Both players get 10 minutes; time runs only on your turn. Lose on time!
  • ๐Ÿ–ผ๏ธ Visual Vibes โ€“ Clean 8ร—8 board with alternating squares and a stylish captured-pieces display.
  • ๐Ÿ”Š Sound Effects โ€“ Custom sounds for moves, captures, checks, checkmates, castling, and more.
  • ๐Ÿ‘‘ Pawn Promotion โ€“ Promote to a queen, rook, bishop, or knight when reaching the last rank.
  • ๐Ÿ•ณ๏ธ En Passant โ€“ Yes, the spicy pawn capture is implemented!
  • ๐Ÿฐ Castling โ€“ Both kingside and queenside castling are supported.
  • ๐Ÿ† Checkmate & Stalemate Detection โ€“ Endgame logic with victory messages and screen dimming.
  • ๐Ÿ”„ Restart Option โ€“ Press R to reset the board and play again after the game ends.
  • ๐Ÿ” Auto-Flipping Board โ€“ The board flips after every move to show the active playerโ€™s perspective.
  • ๐Ÿ“„ PGN Export โ€“ Save your game history in PGN format after each match. Perfect for analysis or bragging rights.
  • ๐Ÿ“œ FEN Support โ€“ Load any chess position from Forsythโ€“Edwards Notation (FEN).

โš™๏ธ Installation

1. Clone the repo

git clone https://github.com/Rayan581/Chess.git
cd chess-game

2. Install dependencies

Make sure you have Python 3.x and Pygame installed:

pip install pygame

3. Prepare assets

Ensure the following structure is present under the assets/ folder:

assets/
โ”œโ”€โ”€ pieces/
โ”‚   โ”œโ”€โ”€ black/
โ”‚   โ”‚   โ”œโ”€โ”€ black-pawn.png
โ”‚   โ”‚   โ”œโ”€โ”€ black-knight.png
โ”‚   โ”‚   โ””โ”€โ”€ ...
โ”‚   โ””โ”€โ”€ white/
โ”‚       โ”œโ”€โ”€ white-pawn.png
โ”‚       โ”œโ”€โ”€ white-knight.png
โ”‚       โ””โ”€โ”€ ...
โ””โ”€โ”€ sounds/
    โ”œโ”€โ”€ move.mp3
    โ”œโ”€โ”€ capture.mp3
    โ”œโ”€โ”€ check.mp3
    โ”œโ”€โ”€ checkmate.mp3
    โ””โ”€โ”€ ...

If not included, you can grab free chess piece PNGs and sound effects online.


โ–ถ๏ธ Running the Game

python main.py

๐ŸŽฎ How to Play

  • Move Pieces: Click a piece to select it. Valid moves will be highlighted. Click again to move.
  • 10-Minute Timer: Both players start with 10 minutes. The clock runs only during your turn. Time out = loss.
  • Pawn Promotion: Reach the last rank and choose from queen, rook, bishop, or knight.
  • Restart: After the game ends, press R to reset and start fresh.
  • Quit: Press ESC or close the window to exit.
  • View Flip: The board flips after each turn for an immersive perspective shift.

๐Ÿ“„ PGN Export

After the game ends (via checkmate, stalemate, or timeout), the game automatically generates a .pgn file in the games folder inside the project folder.

You can:

Each PGN includes:

  • Player names
  • Result (win/loss/draw)
  • Termination reason (checkmate, timeout, etc.)
  • Full move history in official notation

PGN file example: game_2025-07-15_19-34-22.pgn


๐Ÿ“œ FEN Support

You can start from any position using a FEN string! Perfect for studying openings, recreating famous games, or resuming saved positions.

Example FEN strings:

  • Starting position:

    rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
    
  • After 1. e4 e5 2. Nf3 Nc6:

    r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3
    

To use it, just update the board setup in main.py with your FEN string, and the game will load from that position.


๐Ÿ“ Project Structure

chess-game/
โ”œโ”€โ”€ main.py              # Game loop, input, and timer logic
โ”œโ”€โ”€ classes/
โ”‚   โ”œโ”€โ”€ board.py         # Chess board state, rendering, and game rules
โ”‚   โ”œโ”€โ”€ piece.py         # Piece class and movement logic
โ”‚   โ””โ”€โ”€ sound_manager.py # Plays sound effects
โ””โ”€โ”€ assets/              # Piece images and sound files
โ””โ”€โ”€ games/               # PGNS of previously played games

๐Ÿค Contributing

Wanna make this game even more lit? Fork the repo, make your changes, and submit a pull request! ๐Ÿ’ก

Ideas:

  • Add a single-player mode with AI
  • Move history or undo functionality
  • Add increment-style clocks (e.g. +2 seconds per move)
  • Animations, themes, and visual polish
  • LAN or online multiplayer

๐Ÿ“œ License

This project is licensed under the MIT License. Feel free to use, modify, and share โ€” just be chill and give credit where itโ€™s due. โœŒ๏ธ


Made with โค๏ธ, caffeine, and dramatic blunders.


About

โ™Ÿ๏ธ Python + Pygame Chess Game | Full rules (castling, en passant, promotion), timers, sound effects, auto-flip board & PGN export ๐ŸŽฎ

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages