def on_mouse_press(self, x, y, button, modifiers): """ Gestione evento premi tasto mouse :param x: :param y: :param button: :param modifiers: :return: """ # a seconda dello stato verifica se un bottone nella lista è stato premuto if self.__current_state == MENU: Button.check_mouse_press_for_buttons(x, y, self.__button_list_menu_start) if self.__current_state == PAUSE: Button.check_mouse_press_for_buttons(x, y, self.__button_list_pause) if self.__current_state == GAME_WIN or self.__current_state == GAME_OVER: Button.check_mouse_press_for_buttons(x, y, self.__button_list_game_over) if self.__current_state == INSTRUCTION: Button.check_mouse_press_for_buttons( x, y, self.__button_list_instruction) if self.__current_state == LEVELS: Button.check_mouse_press_for_buttons(x, y, self.__button_list_levels)
def __set_button_menu_game_over_win(self): """ Inizializza i bottoni del menu game over/win :return: """ self.__button_list_game_over = [] # bottoni menu game_over/win self.__button_list_game_over.append( Button(3, 0, "RESTART", self.__start_game)) self.__button_list_game_over.append( Button(4, 0, "MENU", self.__set_menu_start))
def __set_button_munu_pause(self): """ Inizializza i bottoni del menu pause :return: """ # bottoni menu pause self.__button_list_pause = [] self.__button_list_pause.append( Button(3, 1, "RIPRENDI", self.__exit_pause)) self.__button_list_pause.append( Button(4, 1, "RESTART", self.__start_game)) self.__button_list_pause.append( Button(5, 1, "MENU", self.__set_menu_start))
def __set_button_menu_start(self): """ Inizializza i bottoni del menu start :return: """ # bottoni menu start self.__button_list_menu_start = [] self.__button_list_menu_start.append( Button(2, 1, "START", self.__start_game)) self.__button_list_menu_start.append( Button(3, 1, "LIVELLI", self.__set_state_elenco_livelli)) self.__button_list_menu_start.append( Button(4, 1, "ISTRUZIONI", self.__set_state_istruzioni)) self.__button_list_menu_start.append(Button(5, 1, "EXIT", sys.exit))
def __set_button_menu_instruction(self): """ Inizializza i bottoni del menu istruzioni :return: """ self.__button_list_instruction = [] # bottone back menu set_state_istruzioni self.__button_list_instruction.append( Button(9, 1, "BACK", self.__set_menu_start))
def __set_button_menu_livelli(self): """ Inizializza i bottoni del menu scelta livelli :return: """ self.__button_list_levels = [] # bottoni menu selezione livello row = 1 column = 0 if DEBUG: print("num_livelli: " + str(Costanti.MAX_LEVEL)) for i in range(1, Costanti.MAX_LEVEL + 1): self.__button_list_levels.append( Button(row, column, "Livello " + str(i), self.__imposta_livello_scelto, bt_id=i)) column += 1 if column == 3: column = 0 row += 1 self.__button_list_levels.append( Button(9, 0, "BACK", self.__set_menu_start))