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
Human-led
Blackjack start screen on green felt with settings, player controls, poker chips and a jack of hearts

Blackjack was the first really big project I completed on my own. I learned each piece as I needed it and slowly built a full multiplayer casino game with accounts, saved statistics, chip betting, splits, insurance, surrender, hotkeys, settings, and a complete round flow. Somehow all 3,372 lines live in one Python file, and somehow it works.

Building it one piece at a time

I did not begin with a grand architecture. I added one feature, figured out what it needed, and then moved to the next. Player and hand classes, dealing, bets, account passwords, lifetime statistics, settings, and all the special blackjack actions gradually became one very integrated game.

Finishing it was incredibly fulfilling. It proved to me that I could keep working through a large idea until the whole thing actually came together, and it pulled me much deeper into coding.

Fitting every hand on the table

One of my favorite details is the card display. The program calculates the angle and offset for every card, then fans the hand inside the space available for that player. As more cards are dealt, the layout tightens itself instead of spilling across the table.

More than hit or stand

The game supports as many as five players at the same keyboard. Players can bet with chips, split hands, double down, surrender, buy insurance, play as guests or sign into accounts, and review balances and lifetime results after a round.

Game walkthrough

The round moves from choosing the number of players and starting balances to placing bets, playing each hand and reviewing 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.