Skip to content
Michael Lizzio

Blackjack

The 3,372-line Pygame casino game that got me hooked on building big projects

  • Python
  • Pygame
  • Persistent text storage
  • Custom layout algorithms

August 2024

Human-led
Blackjack start screen on green felt with settings, player controls, poker chips and a jack of hearts
What it is
A full blackjack game in Pygame for up to five players at one keyboard, with accounts, chip betting, splits, insurance, surrender, saved stats and settings.
Why I made it
I wanted to see if I could finish something really big on my own, so I picked a game I knew and kept adding to it.
What I did
I wrote all of it myself, one feature at a time, learning each piece as I needed it. Somehow all 3,372 lines ended up in one Python file.
How it turned out
It works, and finishing it was incredibly fulfilling. It showed me I could keep going on a big idea until it all came together, and it pulled me a lot deeper into coding.

The details

Building it one piece at a time

I didn't start with a big plan. I added one feature, figured out what it needed, and then moved on to the next one. Player and hand classes, dealing, bets, account passwords, lifetime stats, settings and all the special blackjack moves slowly turned into one big connected game.

Fitting every hand on the table

One of my favorite details is how the cards are drawn. The program works out the angle and offset for every card and fans each hand out in the space that player has. As more cards get dealt, the hand tightens up instead of spilling across the table.

More than hit or stand

Up to five players can play at the same keyboard. You can bet with chips, split, double down, surrender, buy insurance, play as a guest or sign into an account, and check balances and lifetime results after each round.

Game walkthrough

A round goes from picking the number of players and their starting balances, to placing bets, playing each hand and seeing the new balances.

  • Blackjack setup screen for choosing the number of players and each player's starting balance
  • Betting screen for five players with a minimum bet of ten and colored chip controls
  • Five-player blackjack round with the dealer showing a four and player five choosing an action on sixteen
  • Round results overlay showing the dealer on twenty and each player's won or lost result
  • Final balance summary for all five players with a Play Again button

Videos

This shows a full play through of the game and all of its features.