From PyGame to GoDot – What’s Their Difference?

About PyGame

If you would like to use Python to develop 2D game, your first choice might be PyGame, which is popular among Python game developers. Go to the website, you could browse all of the classes and their explanation. All of the stuffs are grouped into the pygame library.

If you do not know where to start off for PyGame development, go to check out on YouTube and there are many high quality tutorials guiding you how to start building game from scratch and utilize those pygame classes flexibly. The learning curve is not flat but it is fulfilling to apply what you have learned about the Python language to create the games. Within this process, you need to create list, dictionary, class and utilize some typical modules such as math, random, sys, etc. It is a great way to understand real power of Python and apply it to real scenario.

About GoDot

I noticed Godot when I watched PyGame tutorial on YouTube. It is the free and open source community-driven 2D and 3D game engine. As you could see in the above image, it offers a powerful yet user-friendly interface that you can use to develop any kind of game, for any platform and with no usage restriction whatsoever. In terms of games and comparing it to Unity, Godot hasn’t exactly matched the power of Unity. Godot is younger and doesn’t have the same 3D power that Unity can harness.

Differences Between PyGame and GoDot

PyGame offers a complete library, including how to load image and text, playing the music and generating sound effect, checking the image overalapping, handling mouse and keyboard events, as well as some more advanced features such as creating mask surface and sprite class.

Different from PyGame, GoDot is a game engine. That means, it has already contained many functionalities in the tool and wrapped them either as UI properties or methods. When users develop game on it, they need to get familiar with the tool and know where and how to use those existing functions and then make them work properly.

Handling Object Collision

For example, in PyGame, when we check if two objects touch each other, we use pygame.Rect.colliderect() to check and return a Boolean value.

However, if the two objects are irregular, or you would like to have a more precise collision check, you need to create a mask surface and check collision by using pygame.mask.overlap(), as the following code shows.

In GoDot, what you need to do is to add a CollisionShape2D node and then specify its collision shape and area. Through hooking area_entered signal to the script, whenver any other sprite enters the node’s area, this signal (event) is triggered.

In the above example, the collision shape in Godot could be specified as rectangle, oval, circle, line, or convexpolygon. It means that even the collision area is irregular, Godot could still create a precise collision shape by using convexpolygon type.

Handling Costume Animation

In PyGame, if you would like to animate different costumes of a sprite, you need to load all the images and save them in a list before main loop starts. In the main loop, you go though the list repeatedly to blit different image on the display surface in each iteration, thus generating animation.

In GoDot, there are several ways to manage multiple costume images. You could put them in folder and sub-folders like in PyGame, and then add AnimatedSprite node. You could drag the costume image to Sprite Frames editor and arrange their sequence and specify their category, just as what the following image shows.

You could also use AtlasSprite, which could load an atlas image (which is an image containing multiple smaller images, usually packed together to reduce overall dimensions). GoDot provides properties to split the atlas image into smaller images by specifying HFrame and VFrame.

Brief Summary

The experience of PyGame and GoDot is much different. When using PyGame, you are writing pure Python code and you need to handle everything from scratch, such as load image and text, playing music and managing the movement of each sprite and their interaction. What you need is an empty Python project and the pygame libary. Your whole project stars from “import pygame” and a generally common project structure. The advantage of using PyGame is that you get to know more lower-level implementation of the game development.

When using GoDot engine, it offers your lots of functionalities and therefore, it takes you some time to get used to its design concept and familiar with its functionalities. You need to know how to develop game which could match its framework. The advantage is that you could design more complicated games and render better visual effects with less code.

In terms of language, GoDot offers several choices. Among them, GDScript is the most common to be used. GDScript Syntax is somewhere between Python and JS, but simpler than both. It uses a syntax similar to Python. Therefore, if you are familiar with Python language or JS, learning GDScript could be a breeze.

Personally, I would suggest that for newcomers of game development, PyGame is a great method for you to improve your Python language skills and get to know how to design 2D game starting from scratch. If you have been pretty familiar with the 2D game development, using GoDot could help you walk around those tedious lower-level code implementation and focus more on realizing visual effects and game plot design.

How to Learn GoDot?

When Learning GoDot, the first step is to follow some online tutorials to go through the basic stuff of GoDot operation. After that, just like learning PyGame, one way I would suggest students to do is to convert some games from PyGame to GoDot. You will find that all of those 2D games could be implemented on Scratch, PyGame or GoDot. That is a great way to improve your coding skills. Enjoy the coding and have fun!

Note: All the analysis articles are copyright products of Anyone re-posting them should credit author and original source. Anyone using them for commercial purposes or translating them into other languages should notify TheCodingFun and get confirmation first. All Rights Reserved.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.