def check_events(self, event: Event): super().check_events(event) x, y = gf.get_mouse_position() #Check for mouse over actions hover: bool = False selected_button: AIButton = None for ai_button in self.__ai_buttons: hover = gf.mouse_in_area(ai_button.get_rect(), (x, y)) if hover: selected_button = ai_button break if self.__selected_button == None: if (hover): # self.get_ai_details_display_screen().set_model_sum_text(selected_button.get_ai().get_model_structure()) self.get_ai_details_display_screen().set_image( selected_button.get_ai().get_image_info_screen_path()) self.prep_ai_idle_image(selected_button.get_ai().get_image()) else: self.get_ai_details_display_screen().set_image( constants.path_img_ai_info_empty) self.__active_ai_image = None # self.get_ai_details_display_screen().set_model_sum_text("") #Check for mouse button presses if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 is left mouse button self.check_ai_button_selection(selected_button, (x, y)) self.check_back_button((x, y)) self.check_choose_button((x, y))
def check_events(self, event: Event): super().check_events(event) if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 is left mouse click x, y = game_functions.get_mouse_position() self.check_finish_button((x, y))
def draw_components(self): super().draw_components() #Color pixel if globals.mouse_left_pressed: x, y = gf.get_mouse_position() collide_with_button = False for button in self.__buttons_to_draw: collide_with_button = button.get_rect().collidepoint( x, y) #Check if the drawing will collide with the buttons if collide_with_button: break if not collide_with_button and not self.__guess_button_pressed: self.__colored_pixels.add((x, y)) for pixel in self.__colored_pixels: pygame.draw.rect( self.get_screen(), self.get_settings().pen_color, Rect(pixel[0], pixel[1], self.get_settings().pen_size, self.get_settings().pen_size)) #Draw buttons for button in self.__buttons_to_draw: button.draw() if not self.__guess_button_pressed: pygame.display.flip() else: self.__guess_button_pressed = False
def check_events(self, event: Event): super().check_events(event) #Check mouse button press events if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 is left mouse click x, y = gf.get_mouse_position() self.check_exit_button((x, y)) self.check_instructions_button((x, y)) self.check_start_button((x, y))
def check_events(self, event: Event): super().check_events(event) #Check mouse button press if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 = Left click globals.mouse_left_pressed = True mouse_pos = gf.get_mouse_position() self.check_clear_button(mouse_pos) self.check_guess_button(mouse_pos) self.check_exit_button(mouse_pos) elif event.type == pygame.MOUSEBUTTONUP: if event.button == 1: #1 = Left click globals.mouse_left_pressed = False
def draw_art(self): """Method to draw the mouse click art""" if globals.mouse_left_pressed: x, y = gf.get_mouse_position() collide_with_button = False for button in self._buttons_to_draw: collide_with_button = button.get_rect().collidepoint(x, y) #Check if the drawing will collide with the buttons if collide_with_button: break if not collide_with_button and not self._guess_button_pressed: self.__colored_pixels.add((x, y)) for pixel in self.__colored_pixels: pygame.draw.rect(self.get_screen(), self.get_settings().pen_color, Rect(pixel[0], pixel[1], self.get_settings().pen_size, self.get_settings().pen_size))
def check_events(self, event: Event): super().check_events(event) x, y = gf.get_mouse_position() #Check for mouse hovers if gf.mouse_on_button(self.get_funhouse_button(), (x, y)): self.get_console().set_image( constants.path_img_gamemode_funhouse_console) elif gf.mouse_on_button(self.get_random_chaos_button(), (x, y)): self.get_console().set_image( constants.path_img_gamemode_random_chaos_console) else: self.get_console().set_image( constants.path_img_gamemode_welc_console) #Check for mouse presses if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 is left click self.check_funhouse_button((x, y)) self.check_random_chaos_button((x, y)) self.check_back_button((x, y))
def check_events(self, event:Event): x, y = game_functions.get_mouse_position() if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: #1 is left mouse button self.check_ok_button((x, y))