Skip to content

Chess game made in Java, re-written for future feature implementations

Notifications You must be signed in to change notification settings

BeraSenol/Chess-Game-Java-2.0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Fully functional chess game written in Java with Spring/AWT GUI & official rule implementations.

Chess_Screenshot

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

Installation

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


Usage

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;

Code Overview

/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 serves GameWindow.java
  • GameWindow.java Main file that runs the game, update() and repaint() 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.

Acknowledgments

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

About

Chess game made in Java, re-written for future feature implementations

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages