When we think about creating video games, the first thing that comes to mind in the context of programming languages is C++ or C#.
Also, if we search Google for answers to the question “Which language should I use?” we’ll quickly come across recommendations to avoid Python.
There is, unfortunately, quite a bit of truth to this, since Python is not designed for computational performance, but rather coding performance.
Python is estimated to be over 25 times slower than C++, which is a really huge difference, especially when it comes to game development—after all, every millisecond is worth its weight in gold in this business!
However, any Python developer who dreams of writing their own game shouldn’t be put off by this right away!
Game development in Python does have some advantages.
Thanks to the language’s simplicity and coding speed, Python is an excellent choice for prototyping. The effect of your work is visible immediately and it’s possible to quickly deliver a playable project to potential investors.
Therefore, Python is also an ideal language to begin your adventure with creating games, regardless of whether you’re already fluent in it or just starting out.
Due to the newcomer-friendly syntax of Python, developers can focus on the basics of game programming, not the complexity of the language itself.
The effects, which are quickly visible, allow beginners to get actively involved in the process of creating a project. Advanced developers, on the other hand, will appreciate the fact that they can create something playable using their everyday work tool, and that the process of coding will be, as always, very enjoyable and satisfying.
When we want to get started with game development, the direction seems obvious: Unreal Engine or Unity.
Unfortunately, these tools don’t support Python in their stable versions. Luckily, there is a light at the end of the tunnel—Python programmers can count on the tools that were written specifically for them.
The most popular library that supports developing games in Python is PyGame. This engine, available under the LGPL, allows you to build fully commercial projects. What’s more, the library is designed in a way that lets you easily use multiple processor cores. The main functions were written in C and Assembler, thanks to which your project will be 10–20 times faster than if it were written in Python only.
Another advantage of PyGame is that it works on any operating system, from Windows to the Dreamcast console. All you need to do to start your adventure with PyGame is have Python 3 installed and run python3 -m pip install -U pygame --user in the environment. When the package is installed, you can immediately start working on your game.
The tool is incredibly easy to learn. Its creators have prepared extensive documentation and a list of guides that are, in their opinion, worth your attention. You can find them here. Personally, I recommend “Python PyGame: The Full Tutorial.” This guide perfectly introduces you to the intricacies of issues such as “Game Loop,” “Event,” or drawing in the game world.
In addition, the authors of the list have prepared some tips for beginners that will allow you to immediately enjoy the process of creating original games and will protect you against frequent mistakes. PyGame is just one example of the means and possibilities to write Python games, while also making it pretty fun!
As your gaming workshop develops and the desire to add a third dimension appears, you can boldly take a look at tools such as Ursina or Panda3D. Of course, these aren’t the only technologies designed for us Python users. The selection of tools available is really big, and engines such as PyOgre, PyKyra, or Ren’Py are also worth your attention.
Lastly, the Kiva library should also be mentioned. It may not have been created with gaming in mind, but it’s perfectly suited for it. Kiva is a multi-platform tool for creating window applications quickly. If you want to see if a game written in Python can be an international success, I recommend EVE Online—a title that attracts over 20,000 players each day!
Thank you for reading my article on developing games in Python! I hope I managed to shed some light on the matter and help you make the right decision when it comes to choosing the programming language for your video game.
STX Next is the place to be for Python enthusiasts such as myself. Since 2005, we have grown to become the largest Python software agency in Europe, and maybe even the whole world.
We have several other resources on the various applications of Python, including:
Our company offers a wide range of software engineering services in Python, Django, and other technologies. If you need support building your next product, just drop us a line and we’ll gladly help you with your project!