Games Python

Good 3D Python Game Engines

Introduction

Finding a framework for 3D game engines made for and with Python can prove very difficult. The reason for this is that Python quickly runs into performance issues when complexity increases. Fast graphics rendering is not what Python does best. However, since Python is very good for creating the logic and is quite popular, you have many options to run frameworks written in C++.

To make this work for 3D game engines, you cannot do everything as you might usually do in Python. Most frameworks create a wrapper for their C++ libraries. You will need to figure out how to compile so that Python can recall this wrapper. They cover in the documentation how to compile for with the Python wrapper.

Game Style and Language Choice

Consider, before you start, whether your game is a platformer, first person shooter, or dialog based. Maybe, you will create a game that challenges intellectual skills. This does not need high performance graphics. The point is that you will need to know what you are trying to achieve before you start. You may be used to Python for programming. But if you are looking to create games with a lot of effects, you should consider other programming languages. It is a great effort to learn a new language, but it is also extremely satisfying once you have passed that initial hurdle of the basics. The time when the regular documentation makes sense, even at a quick glance.

Bindings, Libraries to Consider

To make games, you will need to create graphics, menus, and audio. There are several libraries and Python bindings to handle these cases. One of the most common of these libraries is SDL2, which gives programmers direct access to the video framebuffer, audio output, mouse, and keyboard. Without these, your game will have to use regular routines, which can sometimes be slow. The first version is still around, but SDL2 has all the necessary gadgets.

SFML2 plays a similar role to most multimedia functions, and puts all functions together. In contrast, SDL2 contains many smaller pieces that you need to pull in to your code one at a time.

For Python, you will need the PySDL2 and PySFML2 packages, respectively.

PyOgre

The designers of PyOgre wrote the Ogre framework in C++ with a wrapper for Python. The wrapper is a built-in wrapper. The old project is still available on the web. Following the tutorials can be useful but be careful, as not everything available online will be correct. Ogre has classes for many world objects, giving you a layer on top of OpenGL and Direct3D.

Ogre works with scenes and can create all the graphics you may need for your game. The PyOgre modules work for versions before Ogre version v1.05. After that, there are other modules available. The Ogre software includes Python scripts for importing data from Blender to Ogre. This makes it possible to create your resources in Blender for your game. Other exporters are also available.

http://wiki.ogre3d.org/

Allegro

Allegro handles all the heavy lifting of creating windows, accepting user input, drawing images, and playing sounds – all features that are useful for videogame and multimedia programming. The designers of Allegro do not claim that this program is a game engine, but it is useful for making games.

Since Allegro was built in C++, you will need to create the wrapper to use this program in Python. You can perform this step by compiling from the source. The process creates the classes in a file named allegro.py. Once you have completed this step, you can pick the classes from that file, but it is recommended that you also read the regular documentation for how this program works. This may complicate the process, but learning C++ is also a chore.

https://github.com/liballeg/allegro5

Armory 3D – Blender Extension

This package uses Blender as the development platform and HAXE as the programming language. Yes, you will need to switch to Haxe, but you may convert some existing game logic from Python. Armory3D operates inside Blender as an extension, where you can create all your resources for the game.

Even though Armory 3D does not run on Python, consider this program carefully nonetheless, since you can get started very quickly with this tool. https://armory3d.org/

Urho3D

This package uses Blender as the development platform and uses HAXE as the programming language. Again, you will need to switch to Haxe, but you may convert some existing game logic from Python. Armory3D operates inside Blender as an extension, where you can create all your resources for the game.

Even though Urho3D does not run on Python, consider this program carefully as well, since you can get started very quickly with this tool. https://armory3d.org/

Ursina

Ursina is written in Python and built on Panda3D. This tool is designed to provide many primitives, such as a cube, sphere etc., so that you can move on to the game itself as soon as possible. Panda3D does the deep work and Ursina gives you ready-baked program functions. A player class gives you the options to register pressed keys and mouse movements.

Most of the functions are intuitive to use with clear names and easily understandable functions. You will be able to get started quickly with your game if you use this game-creating tool. Ursina also has tools for converting both blend and psd files.

https://github.com/pokepetter/ursina

Blender Game Engine (?)

Before version 2.79, Blender had a game engine built in. In later versions, however, the designers chose to remove the game engine from the standard build and focus on animations. So, the people over at UPBGE decided to create their own extension that works inside of Blender. You can therefore use Blender to create the entire game. How does this tie into Python game development?

BPGE has an API that allows you to access all the data that you create while working inside Blender. You can use the console inside Blender to access and test the API. In fact, you could write the whole program this way, but that may not be the best choice for your needs. At the very least, you will have all the resources ready and the way you want them from the moment that you create them.

GODOT – GDscript, NOT Python

If you want to write a game and you are comfortable with Python, you also can also use GODOT. This language is very similar to Python only it is especially for writing games.

Conclusion

There are many frameworks for writing games in Python. If you are looking to create high performance 3D games, you should seriously consider learning other languages for those games. Make sure that your program choice allows you to follow your original game idea. If necessary, adapt your programming language to your personal vision.

About the author

Mats Tage Axelsson

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.