From a50b746ee130851b2b66addf3cff1b00dbbdb326 Mon Sep 17 00:00:00 2001 From: chicrobot Date: Thu, 30 Jul 2026 01:23:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=BC=A0=E6=A0=87=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E8=8E=B7=E5=8F=96=E4=B8=8E=E6=82=AC=E5=81=9C=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scenes/main_menu_scene.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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): """