How to Make Chess in Python!

How to Make Chess in Python!

L
LeMaster Tech
45 Video Views·Apr 23, 2025

I made a follow-up to this video adding En passant, castling and pawn promotion available here: https://www.youtube.com/watch?v=s2Dd_obh3fM&t=134s

This is a complete tutorial for a two-player python chess game using the PyGame module. This allows two players to complete in the classic game of chess complete with checking valid moves for all pieces on the board, putting kings in check, and tracking defeated pieces as well as forfeiting and restarting!

ALL CODE AND ASSETS HERE:
https://github.com/plemaster01/pygameChess

Massive thank you to Patreon Supporters Dale and Philip!!
Please consider becoming a super supporter of the channel here:
https://www.patreon.com/LeMasterTech

Consider checking out my personal channel for fun Engineering builds:
https://www.youtube.com/@peterlemaster8310

TIMESTAMPS:
00:00:00 Introduction and Python Chess Showcase
00:03:30 Basic Pygame Setup
00:08:27 Importing Chess Piece Images and Setting up Lists
00:22:56 Drawing the Board
00:34:03 Drawing Chess Pieces Onto Board!
00:42:45 Handling Player Piece Selections
00:56:00 Check Valid Piece Options
01:00:50 Calculate Valid Pawn Moves
01:08:10 Draw Valid Moves Onto the Screen
01:15:55 Calculate Valid Rook Moves
01:29:00 Calculate Valid Knight Moves
01:34:35 Calculate Valid Bishop Moves
01:38:10 Calculate Valid Queen Moves
01:40:52 Calculate Valid King Moves
01:43:39 Draw Captured Pieces onto the Screen
01:48:41 Check if King in Check and Flash on Screen
01:58:31 Checking for Winners and Game Over Handling
02:04:44 Restarting on Game Over