Python for Game Dev: Is It a Good or Bad Idea?

Michał Piórkowski

12 February 2024, 8 min read

thumbnail post

What's inside

  1. Languages Used in Game Development
  2. C++
  3. C#
  4. JavaScript
  5. Java
  6. Python as a Programming Language for Game Development
  7. How to Start Game Development in Python
  8. Final Words

Computer gaming is a concept that has been around for almost as long as computers themselves. “Tennis For Two”, considered the first game in history, was created in 1958! Of course, it did not resemble anything we would consider a real game today, but it was still a simple tennis game.

“Tennis for Two” had none of the fancy graphics video games use today. The cathode ray tube display simply showed a side view of a tennis court represented by just two lines, one representing the ground and one representing the net. The ball was just a dot that bounced back and forth. Players also had to keep score for themselves.

Source

It shows that people have been eager to create something fun since the beginning of the computer revolution.

Today, Game Development is a very hot topic - probably since the moment when smartphones became almost as powerful as computers. Investors put a lot of money in games, making engineers heavily interested in putting their hands on game dev. On the other hand, we have engineers who are willing to create some games just for the fun of it or for their families.

In this article, we will try to see if Python is a good language for game development and who should consider using it for this purpose.

Languages Used in Game Development

When we think about languages used in Game Development, most of us will mention C++ or C#.

Some people will also mention JavaScript or Java. Probably not many will say anything about Python, though. There is a pretty good reason for that, but we will dig into that later - for now, let’s see what the languages mentioned above have to offer - leaving Python out of the equation - just for now.

C++

This is a very fast, object-oriented programming language used vastly by console and windows game creators. It’s also considered a low-level language, making it relatively hard for beginners to learn. It’s a great tool for writing your own Game Engine or creating games within existing ones, like UNREAL Engine, CryEngine, Godot, or Source.

The obvious pros of C++ are:

  • Being cross-platform
  • Being a low-level language makes it “closer” to the Hardware Layer, making the games faster and more efficient
  • It’s extremely fast
  • There are a lot of libraries out there that will help you in many aspects of game development
  • It’s compatible with other languages used in games (like C# or JavaScript), which gives the engineer more flexibility

C#

C# (also known as C Sharp) is a scripting language way more accessible for less experienced engineers. It has an easier syntax that enables you as a programmer to reuse code, making it very efficient.

C# is widely used in the UNITY game engine - which you probably have heard about. Games like “Among Us” or “Pokemon GO” were created in Unity. It’s also very common among VR game developers - most Samsung Gear games use it.

The language itself is also relatively fast, but its biggest advantage is that it’s easier to use than C++.

JavaScript

Most games that are running within the browser are made with JavaScript. Its biggest asset is being cross-platform and low-entry for engineers. Some of the most popular frameworks used among JavaScript game engineers are Three.JS, Famo.US and ImpactJS. Of course, the amount of frameworks is growing daily, so if you plan to create a game in JavaScript, I strongly suggest researching first to see the best fit.

Java

This language may not be as popular as C++, but many large multi-platform games like Minecraft still use it.

Java is beginner-friendly, allows multi-threading, and is great for multiplayer games as it has socket programming. It’s also (as mentioned) cross-platform, so you can create a game that will run on Windows and Linux with just one code.

Python as a Programming Language for Game Development

As we already mentioned initially, Python is not widely used in game development. So it’s simply not the best choice for this purpose. But it doesn’t mean it’s a wrong choice in every case.

First, Python is easy to learn and has a clean and human-readable syntax. This makes it a perfect choice for beginners or experienced programmers who want quick results.

It’s very easy to install and start playing with. In addition, there is a set of modules specifically designed for game development - Pygame.

The speed is relatively good, but Python does not compete with C++ or C# in this area.

If you’re wondering whether you should even consider using Python, we'd say - IT DEPENDS.

In my opinion, Python is great if:

  1. You want to learn the principles of game development fast.

Its coding speed and ease of entry are far better than C++ and C#, so if you want to see whether game development is your “thing”, - we’d definitely suggest using Python.

  1. You want to create a prototype.

Sometimes it’s essential to quickly create a prototype - usually for investors and test user groups. Even if you know that (given that investors will appreciate your idea) you will create the game with C++ or C#, Python is an excellent choice for creating a quick and decent prototype.

  1. You want to create a simple game for FF - Friends and Family.

The obvious choice - there are a lot of engineers who, at some point, decided to create a game just for their kids. In that case, using C++, C#, Java wastes time. Additionally, since Python is easy to write, you will probably have a great time creating the game and not worrying about complex syntax.

  1. Last but not least - Python is a great tool for wroting game plugins. It’s used for example (and even suggested) as a scripting language for Unreal Engine.

There is interesting trivia when it comes to Python. GDScript (the programming language for the Godot game engine) is built similarly to Python (syntax-wise). This makes it very easy for Python programmers to start creating games in the Godot game engine. Of course, this doesn’t in any way promote Python as a game-dev language, but it’s just an interesting fact.

Now that we know in which situations Python would be a good choice, we can also take a quick look at the disadvantages:

  1. Speed
  2. Low compatibility with game engines and programming languages
  3. One cannot create own game engine
  4. A limited number of game libraries
  5. Limited functionality for mobile games

How to Start Game Development in Python

Now that we know some facts about Python, we can make an informed decision about using it in our project. And if we want to use it, let’s take a look at the steps one can take to master its usage in game development.

The obvious (and pretty much only) choice is using Pygame. It’s an open-source library that you can use even for building commercial projects. Using Pygame will also make any game you build faster than plain Python - simply because some functions were written in low-level languages.

If you want to start right away (assuming you have Python3 installed already), you just need to type:

pip install pygame

And you’re set.

The tool itself is very easy to learn with full-blown documentation written by the creators of Pygame - you should check this out - here. There are a lot of tutorials on their site that will guide you through the process without much pain.

Another good starting point would be an excellent tutorial from RealPython.

What is really cool is that Pygame can be used even on Raspberry Pi.

When it comes to 3D graphics (as probably most of you may wonder if it’s possible), you should check out this website. You can find a list of 3D engines and check them out. Personally, we are a big fans of Panda3D - it’s open-source and supports the most popular physics engines.

One last question you may have in mind: can you make a Python game a cross-platform one?

And the answer is (luckily!) - YES.

The creators of Kivy have given us a great tool to easily build and distribute beautiful Python cross-platform GUI./

Isn’t that cool?

Final Words

In conclusion, while Python may not be the traditional choice for high-end game development, its simplicity and versatility make it an excellent option for quick prototypes, learning the basics of game development, or crafting simple games for personal enjoyment.

With tools like Pygame and support for cross-platform development, Python offers a user-friendly entry point into the world of game creation. Whether you're a seasoned developer or a newcomer, consider exploring Python for your game development journey.

Sunscrapers provides 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!

Tags

python

Share

Recent posts

See all blog posts

Are you ready for your next project?

Whether you need a full product, consulting, tech investment or an extended team, our experts will help you find the best solutions.

Hi there, we use cookies to provide you with an amazing experience on our site. If you continue without changing the settings, we’ll assume that you’re happy to receive all cookies on Sunscrapers website. You can change your cookie settings at any time.