Fully functional chess game written in Java with Spring/AWT GUI & official rule implementations.
Features (Screenshots)
- Game Panel
- Game Loop
- Chess Board
- File/Rank Labels
- Chess Pieces
- Legal Move Validation
- Legal Move Indicators
- Player vs Player
- Playable as Black
- Turn Based Movement
- Capture Validation
- Capture Highlight
- Castling Mechanic
- En Passant Mechanic
- Promotion Panel
- King in Check Hightlight
- Legal Move Restriction: King Movement
- Legal Move Restriction: Interposable Piece
- Legal Move Restriction: Re-capturable Checking Piece
- Castle Restriction: Out, Through or Into Check
- Checkmate Detection
Clone:
git clone https://github.com/BeraSenol/Chess-Game-Java-2.0.git
Build and run:
javac -cp src/ Main.java
java -cp src/ Main
Clicking on piece will reveal it's legal moves, click tile to move or re-select another piece to reveal it's legal moves, white always begins.
To play as black change playerColor
in ln30:GameWindow.java
to PlayerColor.Black
.
Default:
private static PlayerColor playerColor = PlayerColor.WHITE;
/board
Board.Java
Class that creates tile objects, draws chess board, creates and places pieces.Tile.Java
Class that define tile objects and hold a piece.TileColor.Java
Enum holding possible tile color values.
/main
App.java
Main Class that servesGameWindow.java
GameWindow.java
Main file that runs the game,update()
andrepaint()
are the main methods which loop the game.Mouse.java
Class that detects mouse events.
/piece
/pieces
-
Bishop.java
Class with movement & capture logic.
-
King.java
Class with movement, capture & castling logic.
-
Knight.java
Class with movement & capture logic.
-
Pawn.java:
Class with movement, capture & en passant logic.
-
Queen.java
Class with movement & capture logic.
-
Rook.java
Class with movement & capture logic.
/promotion
-
PromotionButtonAction.java
Class with JButton ActionListener.
-
PromotionPannel.java
Class with JPanel holding JButtons.
Moveable.java
Interface holding move and capture method.Piece.java
Class holding piece general and common variables/values.PieceColor.java
Enum holding possible piece colors.PieceType.java
Enum holding possible piece types.PlayerColor.java
Enum holding possible player colors.
This project was originally inspired by YouTuber RyiSnow (Thank you very much!):
How to Code Chess in Java
Images found on WikiMedia Commons:
Table of SVG Chess Pieces