diff --git a/src/scenes/main_menu_scene.py b/src/scenes/main_menu_scene.py index a9965ee..02a1d9a 100644 --- a/src/scenes/main_menu_scene.py +++ b/src/scenes/main_menu_scene.py @@ -37,6 +37,9 @@ class MainMenuScene(BaseScene): # 初始化雨滴 self.init_rain(self.rain_max) + # 鼠标位置 + self.mouse_pos = (0, 0) + def update(self): # 按键按下则切换场景 if self.button_status: @@ -51,6 +54,9 @@ class MainMenuScene(BaseScene): # 雨滴坠落 self.rain_fall() + # 更新鼠标位置 + self.mouse_pos = pygame.mouse.get_pos() + def handle_event(self, event): """ 接收主循环传来的事件并处理 @@ -117,6 +123,11 @@ class MainMenuScene(BaseScene): text_rect.y = screen_rect.y + count * 2 * text_rect.height + screen_rect.centerx/2 self.screen.blit(text, text_rect.topleft) count += 1 + # 是否高亮显示 + if text_rect.y < self.mouse_pos[1] < text_rect.y + text_rect.height \ + and text_rect.x < self.mouse_pos[0] < text_rect.x + text_rect.width: + pygame.draw.rect(self.screen, Color.white, text_rect, 1) + def init_rain(self, max_num): """