Debugging Complex Python Games

Diving Deeper in Game Development

I found some other programs and tutorials from the same creator that I used for the simple Python games page, Al Sweigart. For these programs, I used the book Making Games with Python & Pygame because these games use GUI interfaces. They have a buggy version for the reader to recreate the program and test their knowledge of the Python language. Al Sweigart has both the correct version and a bug-riddled version available for the Inkspill (a "Flood It" clone) and Flippy (an "Othello" clone). I initially just wanted to try out the Star Pusher game in chapter 9, but once I finished this project, I found some flaws in the code because of updates to the Pygame library not included in the book.

Star Pusher

A Sokoban clone

The code in the version of the book that I was using was exciting and is one of the first games that I coded that use a graphic interface and the first that uses a predefined map system for each of the 50 levels. The game controls use the arrows to navigate the sprite and the 'a', 's,' 'd,' and 'w' keys to pan the map. Other buttons used in the game are the 'n' key to move on to the next level, the 'b' key to move back a stage, and the 'p' key will switch between sprite characters that the player can use.

Above is a small snippet of the gameplay from the game, including cycling the different characters that can be used throughout the game. The characters do not have any special skills during gameplay, just an aesthetic difference between them. The game's goal is to move the stars to designated blocks to complete each level and go on to the next stage. For my version of the code used in the video, check out the GitHub repository.

Inkspill

A "Flood It" clone

This game uses six different colors that must be matched and eventually must be cleared in the given number of turns. The game also has other leveling systems, including easy, medium, and challenging. There are also different sizes that the game board can be. The small game board is a “6x6”, the medium/default game board is a “17x17”, and the large game board is a “30x30”. The initial board has the colors red, green, blue, yellow, orange, and pink. Five different groups of colors can be picked to use that also change the background of the game.

The different difficulty ratings change the size of the “splotches” of given colors. Below is a clip of the game being played with the various color options and different difficulties. The first play-through is the default settings for the game on medium with the medium size. The second is with a different color scheme, easy difficulty, and the largest game board. To win the game, the player must select a color square at the bottom of the screen. The color at the top left corner of the game, no matter the difficulty or size, is the starting point. For my version of the code used in the video, check out the GitHub repository.

Flippy

A "Reversi" clone

The game code from the book online also included a background image and a board that I added the version that I made. The system uses logic that allows the user to play competitively against the computer. The game's goal is to have the most tiles on the board when the board is filled. The player and the computer have to "enclose" the other player's tiles inside your own to change them from white to black or vice versa. The game ends when the board is full, and the points are allocated by the number of each player's piece on the board, earning one point. Throughout the game, the program tracks the score and displays it. The program compares and calculates the point difference between the user and the computer telling the user the winner and the loser. To see the code that I used for this is in my GitHub repository.