The little book of pygame

Create your own computer minigames

This short, hands-on book walks you through building four different minigames using Pygame, even if you’ve never written a rock paper scissors game before.

With clear explanations and all the source code included, you’ll learn all the fundamentals required to build a game. Whether you’re a hobbyist looking to explore something new or a developer wanting to build fun side projects, this book is designed to get you started quickly and confidently.

No fluff – just practical steps to making your own games from scratch.

Don't buy this book

This short book is not for every Python developer. If you identify with any of the below, please do not buy this book:

  • People who hate fun – If you won't enjoy making your own minigames from scratch, this isn't for you.
  • Those looking for pre-made solutions – If you want to copy-paste code without understanding how it works, this isn't for you.
  • Anti-pythonistas – If you think Python is "too slow" for a game you're better off elsewhere.
  • Game dev elitists – If you're expecting to master Unreal or Unity in 50 pages, you're in the wrong place.
  • People allergic to creativity – If creating, tweaking, and designing your own games feels like a chore, steer clear.
  • Anyone afraid of challenges – If the thought of debugging, problem-solving, and learning something new makes you run, keep running.
  • Fans of boring tutorials – If you prefer dry, overly technical guides without personality, this book might be way too engaging for you.
  • People expecting AAA graphics – If you're here for photorealistic 3D models and can’t handle some raw, unpolished retro charm, this book will drive you nuts.

If you're none of the above, welcome aboard: this book's your next adventure!


Take a look at the games you will be building below:

Swimmy Fish

In this “Flappy Bird” clone the player has to help the fish pass through an infinite series of obstacles that come their way.

Here are some things you'll learn:

  • Physics-Based Movement: Implement realistic physics-based movement with gravity and velocity, making your game feel more authentic and providing players with a satisfying challenge.
  • Procedural Obstacles: Learn how to design procedural obstacles that scroll across the screen, offering an endless challenge. This technique is essential for creating replayable games with ongoing difficulty.
  • Scrolling Backgrounds & Parallax Effect: Add depth to your games using a parallax scrolling effect, where different background layers move at different speeds, giving your game a more immersive and 3D-like feel.


Bubble Pop

In this reaction and precision game players have to click as many shrinking bubbles as possible within the time limit.

Here are some things you'll learn:

  • Interactive Object Management: You’ll learn how to manage and animate interactive objects, such as bubbles that appear, shrink, and disappear based on player input. This is crucial for creating dynamic and engaging game environments.
  • Event-Driven Gameplay: Understand the use of event handling in Pygame to respond to user input, such as mouse clicks. This concept enhances player engagement by making games responsive to real-time interactions.
  • Game Flow Management: The game introduces the concept of game loops and timing mechanics, allowing you to control game duration and pace. Mastering these elements is key to keeping your game fun and challenging.


Memory Tiles

In this pattern recognition game the player has to memorise a pattern of secret tiles and then repeat it in a sequence of increasingly hard levels.

Here are some things you'll learn:

  • Pattern Recognition & Matching: Understand how to create a game based on pattern recognition, challenging players’ memory skills. This adds a cognitive layer to your game design, keeping players mentally engaged.
  • Animating Transitions: You’ll learn how to animate transitions smoothly, making gameplay feel polished and professional. Mastering animation adds visual appeal and fluidity to game experiences.
  • Incremental Difficulty Scaling: This game introduces a progressive difficulty system, allowing you to create games that become more challenging as the player advances—perfect for maintaining long-term engagement.


Maze Navigator

In this game the player has to find their way out of a maze without being able to see the whole maze.

Here are some things you'll learn:

  • Procedural Content Generation: Learn how to generate random mazes using algorithms, giving your game a new layout each time it’s played. Procedural generation keeps games fresh and unpredictable.
  • Player Movement & Collision Detection: This game teaches how to implement player movement and handle collisions with walls, a fundamental concept for any game involving exploration or puzzles.
  • Minimap Design: You’ll create a minimap to give players a sense of orientation, a feature that adds depth to your games by making them more user-friendly and immersive.


Each game builds upon the last, introducing new mechanics and complexities while remaining accessible for anyone familiar with Python. By the end of the book, you'll have the skills to develop your own 2D games using Pygame!