GitXplorerGitXplorer
S

pygame_chess

public
2 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
e69bb145e880f78385378ff5378bd9a0542c75dc

rm pycache and add readme.md

SSadeedpv committed a year ago
Unverified
c88fdd0618ce940421052cbae1e6ed779394becd

Refactor functions

SSadeedpv committed a year ago
Unverified
1988093e5fd7f4fa4ed39534c5811a74a0ff7448

Pawn to Queen

SSadeedpv committed a year ago
Unverified
bd452dad25a2feefa1728aa184e7d3e9d0bba8e1

Add winning logic

SSadeedpv committed a year ago
Unverified
20f50aa5edd5197f1f25270e7d8ca273285949f1

Add the ability to capture pieces

SSadeedpv committed a year ago
Unverified
34132cc8b8a0afe9c1a059adf8b2f3cf80e3079c

Add move logics

SSadeedpv committed a year ago

README

The README file for this repository.

This is a chess game made with pygame.

To run the game, open a terminal window and navigate to the directory where the code is saved. Then type the following command:

python main.py

The game will start and you can play it by clicking on the squares on the chessboard.

Here are some explanations of the code:

  • The pygame library is used to create the graphics and handle the user input.
  • The chessboard is a 2D list that represents the chessboard. Each element of the list is a string that represents the piece that is on that square.
  • The draw_board() function draws the chessboard on the screen.
  • The handleClick() function handles the logic for when the user clicks on a square on the chessboard.
  • The get_moves() function returns a list of all the possible moves for a given piece.

How to play

The game of chess is played between two players, White and Black. Each player starts with 16 pieces:

  • 8 pawns
  • 2 rooks
  • 2 knights
  • 2 bishops
  • 1 queen
  • 1 king

The pieces are arranged on the board as shown in the following diagram:

     a b c d e f g h
8   ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
7  ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
6   . . . . . . . .
5   . . . . . . . .
4   . . . . . . . .
3   . . . . . . . .
2  ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
1   ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖

The objective of the game is to take your opponent's king. To move a piece, click on the piece you want to move and then click on the square you want to move it to(It will show all the possible moves).

I hope this helps!