beanz Magazine

PyGame (or Godot)

Blake Patterson on Flickr

Dive into the nitty-gritty of game-making with this popular Python library.

In the last issue, I talked about my experience in PyWeek, a week-long game jam done specifically with Python and the PyGame library. This week, we’ll talk more about PyGame itself and give some examples of how to do things in it.

To start with, PyGame is a pretty old library but one that’s still being used and updated for a reason: it’s an easy way to write your own game engines in Python.

If you’re not sure what I mean by “game engine” I mean a lot of the real guts of a game. A game engine is the code for things like physics, motion controls, or handling keypresses, mouse movement, and using a controller.

I think of games writing as being on a spectrum: on one end you have things like GameMaker where you don’t necessarily need to do programming to make a game. On the other end you could write all the code to:

  • Talk to the graphics hardware to be able to put colors in specific pixels
  • Load images from files and turn it into something that can be displayed on the screen
  • Ask the operating system for keyboard/mouse/controller inputs
  • Handle refreshing the screen many times a second

Most ways of writing games are in the middle. Things like Unity and Godot are more towards the GameMaker end; meanwhile, something like PyGame is closer to the full DIY way of making games.

Become a subscriber and get access to the rest of this article. Plus all our magazine articles.

Stories also include numerous links to help parents, kids, and teachers learn more. Get access today at just $15 per year for online magazine only or $29.99/year for print + online ($35/year outside US)!

Subscribe Today!

Also In The April 2018 Issue

Who chooses new emojis? And what’s coming in the next batch?

Build your own voice-controlled digital assistant with a Raspberry Pi and an analog speaker.

Using Scratch and some simple vector math, create your own Boids algorithm to simulate the flight of birds.

6 hands-on STEM camps and clubs to join this summer.

With these new high-tech cards, public transit is easier than ever.

Slice digital photos into pieces and have fun pasting them back together.

Meet the cute little bot that’s helping scientists understand the courtship of frogs.

Dive into the nitty-gritty of game-making with this popular Python library.

Learn about the Native soldiers and the creative cypher code that helped win WWII.

Our cars aren’t quite driving themselves, but they can help us park and avoid collisions.

Make your games even more exciting with custom user-created content!

A clever teacher uses our favourite round robot to bring books to life.

Learn how to search through blobs of text with speed, accuracy, and elegance… like a ninja!

Links from the bottom of all the April 2018 articles, collected in one place for you to print, share, or bookmark.

Interesting stories about computer science, software programming, and technology for April 2018.