Python for Game Development - is it a good or bad idea?

Sunscrapers Team

28 September 2022, 8 min read

thumbnail post

Intro

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 that we would consider a real game today, but still - it was 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.

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 Python 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 people 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, of course.

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 to write your own Game Engine or to create 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 allows it to be “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. One of the most popular frameworks that are used among JavaScript game engineers are Three.JS, Famo.US, or ImpactJS. Of course, the amount of frameworks is growing every day, so if you plan to create a game in JavaScript, we strongly suggest doing some research first to see the best fit.

Java

This language is maybe not 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 in the beginning, 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 language 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.

Python is really great if:

  • 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.

  • You want to create a prototype.

Sometimes it’s essential to create a prototype very fast - 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.

  • 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. And additionally, since Python is easy to write, you will probably have a great time creating the game and not worrying about complex syntax.

  • Last but not least - Python is a great tool to write plugins for games. 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 (programming language for 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 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 do 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 using plain Python - simply because some of the 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 - together with full-blown documentation written by the creators of Pygame - you should definitely 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 that allows us to build and distribute beautiful Python cross-platform GUI apps easily.

Isn’t that cool?

Final words

As you see, Python is neither the first nor the best choice for game development - but it’s a great choice in some specific cases, making it a really exciting alternative to proven languages used in games for a long time. It’s also a great way for Python developers to fulfill their dreams (or their kids’ dreams) to create their own games - which can be a really great side-project that helps them find the true joy in programming - something that all of us engineers hopefully should still have.

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.