import pygame import os from AnimatedSprite import * class Game(): def __init__(self): pygame.display.init() self.screen = pygame.display.set_mode((1200,900)) self.clock = pygame.time.Clock() # load images images_main = self.load_sprite_group(50,50,"main.png") # load levels # setup objects self.me = AnimatedSprite(images_main,30) # start print("initializing...") def load_sprite_group(self, w, h, filename): ''' Specs : Master can be any height. Sprites frames width must be the same width Master width must be len(frames)*frame.width Assuming you ressources directory is named "ressources" ''' images = [] master_image = pygame.image.load(os.path.join('images', filename)).convert_alpha() master_width, master_height = master_image.get_size() for i in xrange(int(master_width/w)): images.append(master_image.subsurface((i*w,0,w,h))) return images def start (self): print("starting...") while True: for event in pygame.event.get(): if event.type == pygame.QUIT: return if event.type == pygame.MOUSEBUTTONDOWN: pass self.screen.fill((0,0,0)) time_passed = self.clock.tick(30) self.me.render(self.screen) pygame.display.flip() def main(): game = Game() game.start() if __name__ == "__main__": main()