def __init__(self, parent): super(UI_Options, self).__init__(parent) ui_shader_button = STYLE.create_button(0.1, 0.3, 0.9, 0.38) game_shader_button = STYLE.create_button(0.1, 0.4, 0.9, 0.48) def set_ui_caption(): ui_shader_button.caption.set_text( self.parent.shader_manager.get_ui_shader_name()) def set_game_caption(): game_shader_button.caption.set_text( self.parent.shader_manager.get_game_shader_name()) def change_ui_shader(): self.parent.shader_manager.next_ui_shader() set_ui_caption() def change_game_shader(): self.parent.shader_manager.next_game_shader() set_game_caption() set_ui_caption() set_game_caption() STYLE.set_callback(ui_shader_button, change_ui_shader) STYLE.set_callback(game_shader_button, change_game_shader) back_button = STYLE.create_button( 0.1, 0.5, 0.9, 0.58, "Back", self.parent.create_state_changer(UI_MainMenu)) self.center_frame.add_widget_list( [ui_shader_button, game_shader_button, back_button])
def __init__(self, parent): super(UI_Exit, self).__init__(parent) self.center_frame.add_widget( STYLE.create_label( 0.2, 0.5, 0.8, 0.58, "Are you sure you want to quit ?").caption.set_size(40)) self.center_frame.add_widget( STYLE.create_button(0.2, 0.6, 0.48, 0.68, "Quit", exit)) self.center_frame.add_widget( STYLE.create_button(0.52, 0.6, 0.8, 0.68, "Cancel", self.parent.create_state_changer(UI_MainMenu)))
def __init__(self, parent): super(UI_PlayPacMan, self).__init__(parent) game = PAC.PacManGame(self.parent.minim) game_window = UI.FrameBuffer().set_corners( 0.05, 0.05, 0.95, 0.95).set_shader(self.parent.shader_manager.get_game_shader()) score = STYLE.create_label(0, 0, 1, 0.05, "") def quit_game(): game.quit_game() print "stopping sounds!" self.parent.change_state(UI_MainMenu) self.parent.highscores.add_new_score("Player", game.get_score()) def _update(event): game.update(event) game_window.set_buffer(game.get_frame_buffer()) score.caption.set_text(game.get_score()) self.update_func = _update self.center_frame.add_widget(game_window).add_widget(score).add_widget( STYLE.create_label(0.8, 0, 1, 0.05, "")) self.left_frame.add_widget( STYLE.create_button(0, 0, 0.2, 0.05, "Menu", quit_game))
def __init__(self, parent): super(UI_Highscores, self).__init__(parent) scores = self.parent.highscores.get_scores() padding = 0.02 dy = 0.1 y = 0.1 for i in scores: self.center_frame.add_widget( STYLE.create_label(0.2, y, 0.8, y + dy, i)) y += dy + padding self.center_frame.add_widget( STYLE.create_button(0.2, y, 0.8, y + dy, "Main Menu", self.parent.create_state_changer(UI_MainMenu)))
def __init__(self, parent): super(UI_MainMenu, self).__init__(parent) title = "PyPac" logo = STYLE.create_label(0.2, 0.1, 0.8, 0.4, title) logo.frame = UI.NoneWidget() subtitle = STYLE.create_label(0.2, 0.35, 0.8, 0.45, "python Pacman clone") subtitle.frame = UI.NoneWidget() self.center_frame.add_widget(logo).add_widget(subtitle) y = 0.5 dy = 0.08 padding = 0.02 for i, j in [("Play", UI_PlayPacMan), ("Options", UI_Options), ("Quit", UI_Exit)]: self.center_frame.add_widget( STYLE.create_button(0.2, y, 0.8, y + dy, i, self.parent.create_state_changer(j))) y += dy + padding credit = STYLE.create_label(0.5, 0.9, 1, 0.95, "Created By PolyCrystal") credit.frame = UI.NoneWidget() self.right_frame.add_widget(credit) def fn_update(event): if random.randint(0, 10) < 2: L0 = 0 L1 = 255 txt = "" for i in title: if random.randint(0, 10) < 2: txt += chr(random.randint(L0, L1)) else: txt += i logo.caption.set_text(txt) self.update_func = fn_update