Posted on 2021-01-01 byVlad Călin
For a while now, I am flirting with the idea of making a game, based on a combination of economic simulations and space travel.
But since Python is my go-to language when I build things, and I am more experienced in, why not look for a game
engine in that area? After a few searches, it seemed that the
pygame library is the post popular out there.
But the fact that is was just that, a library was a little concerning that I'll have to build a lot of basic
So I picked it up and tried to create something from scratch in it, just to get the hang of it.
Their documentation structure is a little off-putting, to not mention its very old graphic aspect. It seemed to me to be an almost dead project, even though the project on Github merges code pretty frequently and the community seems to be pretty active.
For me, the structure of the documentation was confusing and doesn't contain very useful information to aid in the development process, and the community seemed to aim to provide the bare minimum: the installation instructions, the module reference and listings of crowd-sourced tutorials with very basic information.
Fortunately, on stack overflow you'll be able to find plenty of help for any kind of issues. But that's it. You'll have to know what to ask in order to get something done. Things about best practices, how to implement certain features will mostly be on you to figure out one tiny step at a time.
Being just a library, it contains the building blocks of building a game, such as drawing shapes and images on the screen, reacting to events, playing sounds and that's pretty much it. You'll have to use these building blocks to do pretty much anything.
For example, building a GUI will be a lot of hassle, you'll have to draw the buttons yourself, the text in them, size them accordingly, detect and react to hover and click events. Anything it is, you'll have to do it from scratch.
I tried to simulate an adaptable layout engine based on containers, that will auto-adjust the sizes and positions of their children, buttons that can fill the available space when needed and some other GUI related things.
It was a lot of work just to get that done. You'll have to think about the architecture and modularity of your app beforehand, if you plan on developing a full-blown game with it.
There are libraries that try to offer more high level approaches to certain things. Sometimes they work, sometimes
they don't and sometimes they seem dead (a lot of utility frameworks or libraries build on top
pygame seem abandoned).
In the end, I decided to not use it for my game, because I value productivity more than having absolute control
over everything. I want to be able to build systems and UI fast, and unfortunately
pygame is not the tool for the
job, at least in my case.
But if you want to exepriment with Python and want to build a small pet project with it, then I say go for it. PyGame provides a good learning experience and forces you to think about the structure of your project and it provides a good field to improve your Python skills.
The intention of this post is not to bash the PyGame project. It's a very nice and useful project, but the thing is that you'll have to adjust your expectation when diving into it. I jumped into it hoping I would fine a more high level game library and that's definitely my fault as I had different expectations.