Gaming in Python : PyGame vs Arcade vs PyGame Zero

I tried writing games in Python a few years ago, but gave up as the only library at the time (Pygame) wasn't very good.

Recently, I came back to Python and found there are now multiple gaming libraries. In this post, I look at PyGame, Arcade, PyGame Zero and Adventurelib.

Is Python a good language for writing games?

The question is: Should we even be writing games in Python?

The answer is: It depends.

Sure, you won't be writing AAA games with Python. But, most of us aren't writing AAA games.

Games are a fun way to learn a new language or become better at a language you already know. Also, it's a fun hobby.

And for these reasons, Python is a great language to learn gaming. In the years I've been away, there are now multiple libraries for gaming in Python. I'm going to look at 3 main ones (and a bonus one).

Let's jump in.

PyGame: Pros and Cons

PyGame is the "standard" library for writing games in Python. It is the most popular and has been around the longest and has the most tutorials.

Pros: Lots of tutorials

Cons:

  • Very basic– not even a physics engine
  • Not very intuitive--some ways to do things are confusing
  • Lots of unnecessary boiler plate code

As you may have noticed, I'm not a fan of Pygame. It's more like a graphics library than a proper game engine. After playing with Phaser (in Javascript) for some time, I can't really use PyGame.

In theory, you can do a lot with PyGame. In practice, it is hard, non-obvious and painful.

Arcade: Pros and Cons

Arcade is an awesome library. For some time, I thought it was the best thing since sliced bread. It was a proper game engine, doesn't have PyGame's weird decisions and unnecessary code. In fact, it was created to overcome the problems with Pygame.

Pros:

  • Arcade is easy and intuitive to use
  • It has some of the best examples and tutorials I've seen – not just in games, but in any library. Most open source libraries give a few basic examples and move on, but Arcade shows you how to build full games. Just look at this example I got from their tutorial:

The code is intuitive and easy to follow. The examples show you how to build your own levels (using Tiled), and things like the camera moving with the user are easy to setup.

Arcade was going to be my favourite thing. But then... (cue horror music)

Cons:

Edited: I got an email from Paul Craven, creator of Arcade, and he told me I hit Arcade at a bad time– during their once-yearly update which had breaking changes.

Based on that, I'm updating my review:

  • The library is still fairly new and can have bugs; also, there can be breaking changes.
  • Also, only works with certain versions of Python- it was working with 3.7, then I updated it and it stopped working till I moved to 3.9 (currently the latest python). I found this unsatisfactory– library owners should support the last 2-3 versions of Python.
  • There are great examples, but otherwise, documentation is poor, and you have to work back from long examples if you want to do one specific thing.

̶T̶h̶e̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶i̶s̶ ̶u̶n̶s̶t̶a̶b̶l̶e̶.̶ ̶F̶o̶r̶ ̶m̶e̶,̶ ̶i̶t̶ ̶w̶a̶s̶ ̶w̶o̶r̶k̶i̶n̶g̶ ̶o̶n̶e̶ ̶w̶e̶e̶k̶,̶ ̶t̶h̶e̶n̶ ̶I̶ ̶u̶p̶g̶r̶a̶d̶e̶d̶ ̶i̶t̶ ̶t̶o̶ ̶t̶r̶y̶ ̶a̶ ̶n̶e̶w̶ ̶f̶e̶a̶t̶u̶r̶e̶ ̶a̶n̶d̶ ̶i̶t̶ ̶w̶o̶u̶l̶d̶n̶'̶t̶ ̶w̶o̶r̶k̶ ̶o̶n̶ ̶W̶i̶n̶d̶o̶w̶s̶.̶
̶I̶ ̶g̶a̶v̶e̶ ̶u̶p̶ ̶o̶n̶ ̶i̶t̶,̶ ̶r̶e̶t̶u̶r̶n̶e̶d̶ ̶a̶ ̶w̶e̶e̶k̶ ̶o̶r̶ ̶2̶ ̶l̶a̶t̶e̶r̶,̶ ̶a̶n̶d̶ ̶i̶t̶ ̶w̶a̶s̶ ̶w̶o̶r̶k̶i̶n̶g̶ ̶o̶n̶ ̶W̶i̶n̶d̶o̶w̶s̶.̶ ̶H̶u̶r̶r̶a̶y̶!̶
̶B̶u̶t̶ ̶t̶h̶e̶n̶ ̶t̶h̶e̶ ̶e̶x̶a̶m̶p̶l̶e̶s̶ ̶s̶t̶o̶p̶p̶e̶d̶ ̶w̶o̶r̶k̶i̶n̶g̶ ̶a̶s̶ ̶t̶h̶e̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶f̶u̶n̶c̶t̶i̶o̶n̶s̶ ̶h̶a̶d̶ ̶c̶h̶a̶n̶g̶e̶d̶.̶
̶A̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶t̶h̶a̶t̶ ̶h̶a̶s̶ ̶b̶e̶e̶n̶ ̶a̶r̶o̶u̶n̶d̶ ̶f̶o̶r̶ ̶a̶t̶ ̶l̶e̶a̶s̶t̶ ̶3̶ ̶y̶e̶a̶r̶s̶ ̶s̶h̶o̶u̶l̶d̶n̶'̶t̶ ̶b̶r̶e̶a̶k̶ ̶b̶a̶c̶k̶w̶a̶r̶d̶ ̶c̶o̶m̶p̶a̶t̶i̶b̶i̶l̶i̶t̶y̶ ̶s̶o̶ ̶e̶a̶s̶i̶l̶y̶.̶
̶I̶ ̶w̶a̶s̶ ̶p̶l̶a̶n̶n̶i̶n̶g̶ ̶t̶o̶ ̶b̶u̶i̶l̶d̶ ̶a̶ ̶w̶h̶o̶l̶e̶ ̶g̶a̶m̶e̶ ̶w̶i̶t̶h̶ ̶t̶h̶i̶s̶,̶ ̶b̶u̶t̶ ̶I̶ ̶d̶o̶n̶'̶t̶ ̶w̶a̶n̶t̶ ̶t̶o̶ ̶b̶e̶ ̶r̶e̶-̶w̶r̶i̶t̶i̶n̶g̶ ̶t̶h̶e̶ ̶g̶a̶m̶e̶ ̶e̶v̶e̶r̶y̶ ̶3̶ ̶w̶e̶e̶k̶s̶.̶ ̶M̶a̶y̶b̶e̶ ̶I̶ ̶h̶i̶t̶ ̶t̶h̶i̶s̶ ̶p̶r̶o̶b̶l̶e̶m̶ ̶a̶t̶ ̶a̶ ̶b̶a̶d̶ ̶t̶i̶m̶e̶,̶ ̶b̶u̶t̶ ̶t̶h̶i̶s̶ ̶t̶u̶r̶n̶e̶d̶ ̶m̶e̶ ̶o̶f̶f̶ ̶A̶r̶c̶a̶d̶e̶.̶
̶A̶r̶c̶a̶d̶e̶ ̶i̶s̶ ̶s̶t̶i̶l̶l̶ ̶a̶n̶ ̶a̶w̶e̶s̶o̶m̶e̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶a̶n̶d̶ ̶h̶a̶s̶ ̶t̶h̶e̶ ̶c̶h̶a̶n̶c̶e̶ ̶t̶o̶ ̶b̶e̶c̶o̶m̶e̶ ̶t̶h̶e̶ ̶t̶o̶p̶ ̶l̶i̶b̶r̶a̶r̶y̶ ̶i̶n̶ ̶P̶y̶t̶h̶o̶n̶ ̶g̶a̶m̶i̶n̶g̶.̶ ̶I̶ ̶d̶o̶ ̶h̶o̶p̶e̶ ̶t̶o̶ ̶r̶e̶t̶u̶r̶n̶ ̶t̶o̶ ̶t̶h̶i̶s̶ ̶i̶n̶ ̶a̶ ̶f̶e̶w̶ ̶m̶o̶n̶t̶h̶s̶,̶ ̶s̶e̶e̶ ̶i̶f̶ ̶e̶v̶e̶r̶y̶t̶h̶i̶n̶g̶ ̶h̶a̶s̶ ̶s̶e̶t̶t̶l̶e̶d̶ ̶d̶o̶w̶n̶.̶

PyGame Zero: Pros and Cons

Finally, we come to PyGame Zero. Supposedly built for beginners, I found it a million times better and usable than Pygame.

It's so easy, you can literally make a game in 30-60 minutes. And it brought back the joy of Python programming.

I'll start with the cons first:

Cons:

  • It's a library for learning, so it doesn't have support (yet) for advanced features, like using a designed level. But you know what? That's not easy in Pygame either. And besides, if you are just starting out in gaming, designing a level is hardly the first stage.
  • Not a lot of tutorials, as it's still new. If you type Pygame Zero in Google, you will get results for boring old Pygame.

Pros:

  • Really easy!
  • Really intuitive. Things like handling key presses, mouse clicks, showing objects/images on the screen is really easy
  • Fun!

I built 2 simple games using Pygame Zero. The 1st took less than 30 minutes, a clone of Arkanoid (Breakout):

The 2nd took a bit longer, but only because I was trying to overengineer it. I was trying to build a tank fight game, with multiple AI enemies, walls and battle plans but it became too complex.

So I cut it down into a silly game I call Tanks vs Zombies:

And there you go. The whole game is less than 200 lines of code- -and that includes the zombie "ai", the movement and shooting logic.

Honorary Mentions:  AdventureLib and RenPY

Adventurelib for text-based games

Adventurelib is useful if you want to write old-style text adventure games.

It's very simple and basic, but that's the whole point.

RenPy for Visual Novels

Renpy is great if you want to write visual novels– just note that this requires more work on the graphics part and less on the coding.

Conclusion – Arcade and PyGame Zero

If you are starting out in gamedev, or are new to Python and want to build cool games fast, I recommend starting with PyGame Zero.

Arcade is good but too rough at the moment. I will wait for it to settle down before trying to build a full game in it.

I plan to write articles on how I built these games. If you are interested in learning how to then please sign up below.