This the most basic test for PyGame that I have, give it a fly ...
[php]import pygame
from pygame.locals import *
yellow = (255,255,0) # RGB color tuple
# initialise screen
pygame.init()
screen = pygame.display.set_mode((350, 250))
pygame.display.set_caption('Basic Pygame program')
# fill background
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill(yellow)
# display some text
font = pygame.font.Font(None, 36)
text = font.render("Hello from Monty PyGame", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
background.blit(text, textpos)
# blit everything to the screen
screen.blit(background, (0, 0))
pygame.display.flip()
# event loop
while 1:
for event in pygame.event.get():
if event.type == QUIT:
raise SystemExit
screen.blit(background, (0, 0))
pygame.display.flip()
[/php]
Powerful stuff that SDL, mind you, just a little complex at first blush!
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
Make sure you have the right version of PyGame downloaded. I use Windows XP and Python24 so I downloaded the installer file:
pygame-1.6.win32-py2.4.exe
from http://www.pygame.org/
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
I understand that PyGame is simply a wrapper for SDL. That creates a problem, Python has a good memory manager, but SDL written in C++ has the usual memory management is up to you thing. THESE TWO WORLDS LIKE TO CLASH AND CRASH!
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
I have played around with some of the pygame examples posted on the net, and they don't always behave well! I actually managed to get the "grey screen of death" on Windoze XP!
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417