def main(): pygame.init() world = World(pygame.display.set_mode(SCREEN_SIZE)) pygame.display.set_caption('Gatherers') background = pygame.Surface(world.screen.get_size()) background = background.convert() background.fill(BACKGROUND_COLOR) world.screen.blit(background, (0,0)) pygame.display.flip() clock = pygame.time.Clock() gatherers = pygame.sprite.Group() for i in range(20): x = random.randint(0,world.screen.get_width()) y = random.randint(0,world.screen.get_height()) world.addGoody((x,y)) while 1: clock.tick(30) for event in pygame.event.get(): if event.type == QUIT: return elif event.type == KEYDOWN and event.key == K_ESCAPE: return elif event.type == MOUSEBUTTONDOWN: m = pygame.mouse.get_pressed() if m[0]: world.addGatherer(pygame.mouse.get_pos()) if m[2]: world.addEnemy(pygame.mouse.get_pos()) world.update() world.screen.blit(background, (0,0)) world.draw() pygame.display.flip()
def isShiftDown(): return pygame.key.get_pressed()[pygame.K_LSHIFT] or pygame.key.get_pressed()[pygame.K_RSHIFT] #Initialize variables txt = None with open('testMap.txt', 'r') as file: txt = file.readlines() world = World(txt) world.player.speed = 4 world.player['beard'] = 'mustache' world.player['right hand'] = 'dagger' world.player['left hand'] = 'arrow' for i in range(5): world.addEnemy() camera = Camera(background, world, 1) profile = cProfile.Profile() profile.enable() #main infinite loop def main(): # default event loop for event in pygame.event.get(): # Quit conditions if event.type == pygame.QUIT or pygame.key.get_pressed()[pygame.K_ESCAPE]: return False