def reset_game(self): _scores = load.scores(self._score) self._top_score = sorted(_scores, key=lambda k: k['score'])[-1]['score'] self.hud.top_score = self._top_score # destroy gane objects while self._event_stack_size > 0: self.pop_handlers() self._event_stack_size -= 1 for obj in self.physical_objects: obj.delete() self.spawn_condition = 3 self.asteroids_remaining = 0 self._lives = 4 self.hud.lives = self._lives self._score = 0 self.hud.score = self._score self._spawn = 0 self.physical_objects = [] self.particles = [] self.player_ship = player.Player( screen_size=(self.width, self.height), x=self.width/2, y=self.height/2, batch=self.game_batch ) self.physical_objects.append(self.player_ship) # load game evnet handlers for obj in self.physical_objects: for handler in obj.event_handlers: self.push_handlers(handler) self._event_stack_size += 1
def save_score(self): load.scores(self._score)