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.
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.
You can simply install Panda3D via pip
pip install Panda3D
Example:
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()
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
You can simply install Cocos2D via pip
pip install cocos2d
Example:
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()
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.
You can simply install Pygame via pip
pip install pygame
Example:
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()
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!
You can simply install Pyglet via pip
pip install pyglet
Example:
import pyglet
window = pyglet.window.Window()
@window.event
def on_draw():
window.clear()
pyglet.app.run()
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.
First of all you need to install the dependency for kivy
pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
After that you can install kivy
pip install kivy
Example:
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 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.
Thanks for reading !
Originally published by Parwiz at codeloop
#python #game #developer