All pastes #498681 Raw Edit

Stuff

public python v1 · immutable
·published 2007-05-20 16:29 UTC
rendered paste body
 import os, sysimport pygame from pygame.locals import * if not pygame.font: print 'Warning, fonts disabled'if not pygame.mixer: print 'Warning, sound disabled' # underscore_separated variable names# camelCaps methods# CamelCaps classes # Actors are anything that loads in front of the background and affects gameplay or results from it.# Zombies, players, power-ups, projectiles, etc. class GameMain:               def __init__(self, width=800, height=600):                pygame.init()                self.width = width                self.height = height                self.screen = pygame.display.set_mode((self.width,self.height))         def gameLoop(self):                self.loadBackground()#              self.loadInitialActors()                 while 1:                        for event in pygame.event.get():                                if event.type == pygame.QUIT:                                        sys.exit()                        self.screen.blit(self.background,(0,0))                        pygame.display.flip()         def loadImage(self, name, colorkey=None):                fullname = os.path.join(os.path.join('data', 'images'), name)                try:                        image = pygame.image.load(fullname)                except pygame.error, message:                        print 'Cannot load image:', fullname                        raise SystemExit, message                image = image.convert()                if colorkey is not None:                        if colorkey is -1:                                colorkey = image.get_at((0,0))                        image.set_colorkey(colorkey, RLEACCEL)                return image, image.get_rect()         def loadBackground(self):                locale, rect = self.loadImage('map.png')                self.background = locale if __name__ == "__main__":        MainWindow = GameMain()        MainWindow.gameLoop()