In this article we are going to have Introduction to Python Top Game Engines, also i will show you the installation process with example for these Game Engines. as you know Python is one of the top trending language,
and there are some frameworks that you can create games in python.
Also you can check Python Top 5 GUI Frameworks
Python Top 5 GUI Frameworks Introduction & Installation
1. Panda3D
Panda3D is a powerful 3D engine written in C++, with a complete set of Python bindings. Unlike other engines, these bindings are automatically generated, meaning that they are always up-to-date and complete: all functions of the engine can be controlled from Python. All major Panda3D applications have been written in Python,
Panda3D now supports automatic shader generation, which now means you can use normal maps, gloss maps, glow maps, HDR, cartoon shading, and the like without having to write any shaders.
Panda3D is a modern engine supporting advanced features such as shaders, stencil, and render-to-texture. Panda3D is unusual in that it emphasizes a short learning curve, rapid development, and extreme stability and robustness. Panda3D is free software that runs under Windows, Linux, or macOS.
Installation
You can simply install Panda3D via pip
1 |
pip install Panda3D |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from direct.showbase.ShowBase import ShowBase class MyApp(ShowBase): def __init__(self): ShowBase.__init__(self) self.scene = self.loader.loadModel("models/environment") self.scene.reparentTo(self.render) self.scene.setScale(0.25, 0.25,0.25) self.scene.setPos(-8, 42, 0) app = MyApp() app.run() |
So now run the code and this will be the result
2. Cocos2D
Cocos2d is an open source framework that is used to build 2D games, and other cross-platform GUI-based interactive programs. It is written in Python using pyglet library. It Targets the Operating Systems linux, mac or windows on Pc-like hardware.
Cocos2d’s core element is sprite. Basically, it is a simple 2D image that can also contain other sprites. They can be moved, scaled, rotated, have their image changed, etc
Installation
You can simply install Cocos2D via pip
1 |
pip install cocos2d |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import cocos class MyApp(cocos.layer.Layer): def __init__(self): super(MyApp, self).__init__() label = cocos.text.Label('Cocos Game Engine', font_name = 'Times New Roman', font_size = 30, anchor_x ='center', anchor_y='center') label.position = (320, 240) self.add(label) def main(): cocos.director.director.init() app_layer = MyApp() main_scene = cocos.scene.Scene(app_layer) cocos.director.director.run(main_scene) if __name__ == "__main__": main() |
So now run the code and this will be the result
3. Pygame
Pygame is free and cross-platform Python modules designed for writing multimedia applications and video games. It includes computer graphics and sound libraries designed to be used with the Python programming language. pygame is built on top the SDL library, So SDL stands Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. Like SDL, pygame is highly portable and runs on nearly every platform and operating system.
Installation
You can simply install Pygame via pip
1 |
pip install pygame |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import pygame pygame.init() screen = pygame.display.set_mode((400,300)) done = False while not done: for event in pygame.event.get(): if event.type == pygame.QUIT: done = True pygame.display.flip() |
So now run the code and this will be the result
4. Pyglet
pyglet is a cross-platform windowing and multimedia library for Python, intended for developing games and other visually rich applications. It supports windowing, user interface event handling, OpenGL graphics, loading images and videos, and playing sounds and music. pyglet works on Windows, OS X and Linux.
Some of the features for pyglet
- No external dependencies or installation requirements.For most application and game requirements, pyglet needs nothing else besides Python, simplifying distribution and installation.
- Take advantage of multiple windows and multi-monitor desktops.pyglet allows you to use as many windows as you need, and is fully aware of multi-monitor setups for use with fullscreen games and applications.
- Load images, sound, music and video in almost any format.pyglet can optionally use ffmpeg to play back audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as DivX, MPEG-2, H.264, WMV and Xvid.
- pyglet is provided under the BSD open-source license, allowing you to use it for both commercial and other open-source projects with very little restriction.
- Supports Python 2 and 3.Pick your favorite!
Installation
You can simply install Pyglet via pip
1 |
pip install pyglet |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import pyglet window = pyglet.window.Window() @window.event def on_draw(): window.clear() pyglet.app.run() |
So now run the code and this will be the result
5. Kivy
Kivy is Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. Also it is used for game development.
Kivy runs on Linux, Windows, OS X, Android, iOS, and Raspberry Pi. You can run the same code on all supported platforms.
Installation
First of all you need to install the dependency for kivy
1 |
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew |
After that you can install kivy
1 |
pip install kivy |
Example:
1 2 3 4 5 6 7 8 9 10 11 |
from kivy.app import App from kivy.uix.label import Label class TestApp(App): def build(self): return Label(text = 'Hello Kivy World') TestApp().run() |
So now run the code and this will be the result
Conclusion
So if you have plan to build a 3D game in Python , it will be a good idea to use Panda3D Game Engine,
and if you want to build a 2D game in Python, you can use Cocos2D or Pygame.
Also you can watch the complete video for this article
Subscribe and Get Free Video Courses & Articles in your Email