def main_screen(screen): clock = pygame.time.Clock() game_surface = pygame.Surface((600, 600), 0, screen) score_surface = pygame.Surface((200, 600), 0, screen) start_button = Button((180, 430), 'start.png', 'start_covered.png') exit_button = Button((420, 430), 'exit.png', 'exit_covered.png') hiscores = HiScores() while True: clock.tick(FPS) game_surface.blit(IMG_DARTSBOARD_OFF, (0, 0)) score_surface.blit(IMG_CHALKBOARD, (0, 0)) for e in pygame.event.get(): if e.type == QUIT: raise GameInterruptedError elif e.type == MOUSEBUTTONDOWN: if start_button.covered(): return if exit_button.covered(): raise GameInterruptedError start_button.render(game_surface) exit_button.render(game_surface) hiscores.render(score_surface) screen.blit(game_surface, (0, 0)) screen.blit(score_surface, (600, 0)) # update pygame.display.update()
def play(self): pygame.mouse.set_visible(False) for i in range(21): turn = Turn( i, self.screen, self.game_surface, self.score_surface, self.score, ) turn.play() hiscores = HiScores() hiscores.check_and_save(self.score.total)
def setup(self): """Setup game.""" pygame.init() image = pkg_resources.resource_filename(__name__, 'data/icon.gif') pygame.display.set_icon(pygame.image.load(image)) pygame.display.set_caption("tris") self.tileset = Tileset('data/blocks.gif', 16, 16) image = pkg_resources.resource_filename(__name__, 'data/splash.gif') self.splash_image = pygame.image.load(image) self.font = Font() self.hiscores = Persistor.load() if not self.hiscores: self.hiscores = HiScores.get_default_hiscore_list()