def __init__(self): pyglet.window.Window.__init__(self, width=self.SIDE, height=self.SIDE, caption='sim') self.settings_path = get_settings_path('Sisyfos') self.high_score_list = highscore.load(self.settings_path) if not self.high_score_list: self.high_score_list = \ highscore.HighScoreList(self.HIGH_SCORE_LIST_SIZE) self.high_score_list.insert_score('foo', 1) highscore.save(self.settings_path, self.high_score_list) self.start_screen = StartScreen(self.width, self.height, self.VERSION_STRING, self.high_score_list, 5, self.start_game) self.mode = self.start_screen
def handle_event(e): global player, name, clear_time global cheat_key, cheat_name # prev_dx = boy.dx if e.type == SDL_QUIT: gfw.quit() elif e.type == SDL_KEYDOWN: if boss.get_boss_die() != 0: if e.key != None: if 32 <= int(e.key) and e.key <= int(126): if len(name) < 13: name += chr(e.key) elif e.key == SDLK_BACKSPACE: name = name[:-1] elif e.key == SDLK_RETURN: highscore.load() highscore.add(clear_time, name) highscore.save() gfw.change(start_state) clear_time = 0 elif e.key == SDLK_ESCAPE: gfw.push(pause_state) elif e.key == SDLK_r: if player.die_value == 1: gfw.change(start_state) elif e.key == SDLK_1: cheat_key = True elif cheat_key == True: if e.key != None: if 32 <= int(e.key) and e.key <= int(126): cheat_name += chr(e.key) elif e.key == SDLK_RETURN: check_cheat() elif e.type == SDL_KEYUP: if e.key == SDLK_1: cheat_key = False player.handle_event(e)
def save_high_score(name): self.high_score_list.insert_score(name, points) highscore.save(self.settings_path, self.high_score_list) self.mode = self.start_screen self.mode.on_resize(self.width, self.height) self.mode.make_high_score_labels()