def update_colors(self): current_lerp_time = GameMath.inverse_lerp(self.last_changed_beat, self.last_changed_beat + MusicManager.crotchet * self.beats_to_change, MusicManager.get_song_position()) p1 = Levels.levels[GameManager.currentLevelIndex].current_palettes[0] p2 = Levels.levels[GameManager.currentLevelIndex].current_palettes[1] if self.fading_in: Colors.currentPalette = GameMath.palette_lerp(p2, p1, current_lerp_time) else: Colors.currentPalette = GameMath.palette_lerp(p1, p2, current_lerp_time)
def update(self): if not MenuManager.showingCredits and not MenuManager.selectingLevels: if (pygame.key.get_pressed()[pygame.K_RIGHT] or pygame.key.get_pressed()[pygame.K_DOWN] ) and not self.previous_right and not self.previous_down: self.switch_fx.play() if self.currentTarget == 2: Camera.rotation = -2 * math.pi / 6 + math.pi / 6 self.currentTarget += 1 if (pygame.key.get_pressed()[pygame.K_LEFT] or pygame.key.get_pressed()[pygame.K_UP] ) and not self.previous_left and not self.previous_up: self.switch_fx.play() if self.currentTarget == 0: Camera.rotation = 8 * math.pi / 6 self.currentTarget -= 1 if pygame.key.get_pressed()[pygame.K_RETURN] and not self.last_enter: if self.currentTarget == 0 and not MenuManager.selectingLevels: # Play MenuManager.selectingLevels = True LevelPointer.current_level = 0 self.sweep_fx.play() elif self.currentTarget == 1 and not MenuManager.showingCredits: # Credits MenuManager.showingCredits = True self.sweep_fx.play() elif self.currentTarget == 2: # Exit self.sweep_fx.play() pygame.quit() sys.exit(0) elif self.currentTarget == 0 and MenuManager.selectingLevels: # Confirm level selection MenuManager.level_to_load = LevelPointer.current_level self.sweep_fx.play() if pygame.key.get_pressed()[pygame.K_BACKSPACE]: if MenuManager.selectingLevels or MenuManager.showingCredits: self.sweep_fx.play() MenuManager.selectingLevels = False MenuManager.showingCredits = False self.currentTarget = self.currentTarget % 3 self.level_to_play = self.level_to_play % 3 self.previous_left = pygame.key.get_pressed()[pygame.K_LEFT] self.previous_right = pygame.key.get_pressed()[pygame.K_RIGHT] self.previous_up = pygame.key.get_pressed()[pygame.K_UP] self.previous_down = pygame.key.get_pressed()[pygame.K_DOWN] self.last_enter = pygame.key.get_pressed()[pygame.K_RETURN] Camera.rotation = GameMath.lerp( Camera.rotation, self.currentTarget * math.pi / 3 + math.pi / 6, 0.15) Colors.currentPalette = GameMath.palette_lerp( Colors.currentPalette, Colors.menuPalettes[self.currentTarget], 0.15)