I was planning on making a small 2D game in Python. Are there any libraries for this? I know of:
• Pygame - As far as I know it's dead and has been for almost a year
• PyOgre - Linux and Windows only(I do have those, but I want multi-platform)
• Cocos2D - Won't install and cant find any support
• PyCap - Can't find any documentation
• Panda3D - Dead since 2011 + overkill for what I need
• PyOpenGL - Overkill
Any help on what to do with this would be appreciated. I am making games mainly in Lua but I'd like to make one in Python for fun. I also understand that Python isn't exactly the *BEST* choice programming a game, but I have heard it is possible. Tell me if it's true. Thanks!
Hi,
I only have looked closer in pygame. But before asking for an general
overview of possible gaming libraries, I would start to answer the
question of what kind of game you want to make and what features do you
really need.
For some space game for example it is most unlikely that you will face
the requirement of having a bleeding edge physics engine. Especially if
you make use of 2d objects versus 3d models of any type. I guess you can
expand the latter to any extend here.
Also it is a common thing I might guess bravely, that the basics of game
programming are done similar in all game engines.
- Setting up a game loop
- Calculation present and future ob objects
- Handling user input by using events
- Redraw the screen
And this is in pygame quite simply, but I also had trouble finding the
right entrance to it, as you have to read a bit up on how components fit
together in that library.
An example basic setup looks like (with classing), I remove my code and
limited it to basic event/input handling and also the drawing of a
screen object in which you can add images and stuff.
Sorry for the formatting, I copied from idle and formatted in my email
client.
#----------------------------------------
class gameApp:
def __init__(self):
pygame.init()
self.clock = pygame.time.Clock()
self.screen = pygame.display.set_mode( (640, 480),
DOUBLEBUF|SRCALPHA )
self.run()
def run(self):
while not self.close_app:
self.clock.tick(60)
for event in pygame.event.get():
#print event
if event.type == KEYUP:
# Press tab for player info
if event.key == 9:
pass # Do something in tab key
elif event.type == MOUSEBUTTONDOWN:
if event.button == 1:
pass # Left click, mouse button is pressend
elif event.type == MOUSEMOTION:
mx = event.rel[0]
my = event.rel[1]
continue
elif event.type == QUIT:
self.close_app = True
self.screen.fill( (0,0,0) )
# Self interaction is a screen drawing object
self.screen.blit(self.interactions, (0,0),
special_flags=BLEND_RGBA_ADD)
pygame.display.flip()
pygame.quit()
if __name__ == '__main__':
import pygame
from pygame.locals import *
gameApp()
#----------------------------------------
Regards
Jan