Welcome to the SFML Chess Game — a fully interactive, two-player chess experience developed using C++ and the SFML (Simple and Fast Multimedia Library). This project brings a digital twist to the timeless game of chess with intuitive controls, beautiful pixel art, and sound effects.
- Standard 8x8 chessboard with all major pieces: Pawn, Rook, Knight, Bishop, Queen, and King.
- Fully mouse-controlled: click-and-drag mechanics for intuitive piece movement.
- Turn-based two-player mode (Black vs. White).
- Capturing mechanics implemented for all pieces.
- Partial check detection (no checkmate logic).
- Start screen and in-game back-to-menu functionality.
- Pixel-art style chess piece sprites:
pawnblack.png,pawnwhite.pngrookblack.png,rookwhite.pngknightblack.png,knightwhite.pngbishopblack.png,bishopwhite.pngqueenblack.png,queenwhite.pngkingblack.png,kingwhite.png
- Backgrounds:
bg.jpg,bg2.jpg,background.jpg - Menu elements:
button.png,backbutton.png
- Includes a movement sound effect (
4.mp3) played on each successful move.
- Pawn: One square forward (or two on the first move), captures diagonally.
- Rook: Moves any number of squares horizontally or vertically.
- Knight: L-shaped movement (jumps over pieces).
- Bishop: Moves diagonally any number of squares.
- Queen: Combines the moves of a rook and bishop.
- King: Moves one square in any direction.
- 8x8 board with 80x80 pixel cells.
- Each grid square can detect piece presence and valid movements.
- Highlights the selected square for better UX.
main.cpp: Game entry point and main loop.chessmen: Abstract base class with virtual methods for all piece types.Pawn,Rook,Knight,Bishop,Queen,King: Derived classes for each piece’s behavior.Grid: Manages board state and piece positions.Screens: Manages UI screens like menu and gameplay.Buttons: Detects mouse hover/click on buttons.- Uses SFML for:
- Rendering (graphics)
- Event handling (mouse/keyboard)
- Audio (piece movement sound)
- C++ compiler (g++, clang++, MSVC)
- Install SFML and configure your compiler to link it properly.
- Texture and audio files (included)
- Install SFML on your system and configure it with your C++ environment.
- Place all asset files in the following folder structure:
ProjectFolder/ ├── Textures/ │ ├── pawnblack.png │ ├── pawnwhite.png │ ├── ... (other pieces and backgrounds) ├── Music/ │ └── 4.mp3 └── main.cpp - Compile and run using your preferred method:
g++ main.cpp -o chess -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio ./chess
- Use your mouse to interact with the menu and drag chess pieces to valid squares.
Want to try without compiling?
- Download the ZIP release
- Extract the folder.
- Run the provided
.exefile inside to launch Chess instantly!
This project demonstrates:
- Object-Oriented Programming (OOP)
- Inheritance & Polymorphism
- SFML-based graphics and sound
- Event-driven architecture
- Custom UI design in C++
Have suggestions or want to contribute? Feel free to open issues or pull requests!