Simpsons Slot Machine

Simpsons slot machine in Python

5. July 2018

Raspberry Pi is a FANTASTIC device and super fun toy. One of the most popular coding languages for the Pi is Python. I messed around with Python a few years back (I made an exam project in Python when I was in high school) but haven’t touched it in the last three years or so. My exam project in high school was a CLI (Command Line Interface)-styled slot machine. It was extremely simple but also a lot of fun to make, so I figured I would try to make a proper slot machine game this time around.

What GUI module to use

I have some experience with the TKinter module for Python but I knew that it wasn’t really that great of handling animations or screen refreshes. As a result I choose a module called Pygame. This module is well documented, has a large userbase and a great community supporting it. Learning it isn’t that difficult if you already have some experience with TKinter or some other GUI library. What’s great about this module is that you can specify what area of the screen you want to be refreshed instead of having the entire display refresh each time some movement happens. This cuts down massively on the CPU power required – which is a BIG plus on hardware like the Raspberry Pi with limited resources.

GUI, CLI, Theme?

As previously mentioned my first slot machine game from high school was CLI-based and I really wanted some GUI experience in Python so one of the first things I needed to figure out was what kind of theme the game needed to have. After some thinking, I settled with a Simpsons theme.

Code and game mechanics

Since the code for this project is on GitHub and is well commented within the code itself I won’t go over how it works. The game automatically gives you 1000 credits to begin with. Using the 1, 2, and 3 number keys you can bet 10, 50, and 100 credits respectively. With the 4, 5, and 6 number keys you can change how many playlines you want to bet on. To activate the game you press the arrow down key.

Where to get the code

The code is available on my GitHub: github.com/SuneKuntz/Simpsons-Slot-Machine/ . Feel free to download the code and make all the changes you want! Make a different theme, add new functions, change the workings of the code: open-source rocks!