From ecbb70d13416feedc9ca8122fe41281088d60fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Sun, 24 Apr 2022 13:31:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E9=A2=84=E8=A7=88=E4=B8=8E?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=9A=84=E6=A3=80=E6=9F=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/mainmenu.py | 41 +++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/source/state/mainmenu.py b/source/state/mainmenu.py index 8028abe..157effa 100644 --- a/source/state/mainmenu.py +++ b/source/state/mainmenu.py @@ -71,23 +71,40 @@ class Menu(tool.State): self.option_timer = 0 self.option_clicked = False - def checkHilight(self, x, y): - # 高亮冒险模式按钮 + def inAreaAdventure(self, x, y): if (x >= self.option_rect.x and x <= self.option_rect.right and y >= self.option_rect.y and y <= self.option_rect.bottom): - self.adventure_highlight_time = self.current_time - elif (x >= self.exit_rect.x - 20 and x <= self.exit_rect.right + 20 and - y >= self.exit_rect.y - 5 and y <= self.exit_rect.bottom + 10): - self.exit_highlight_time = self.current_time - elif (x >= self.littleGame_rect.x and x <= self.littleGame_rect.right and + return True + else: + return False + + def inAreaExit(self, x, y): + if (x >= self.exit_rect.x and x <= self.exit_rect.right and + y >= self.exit_rect.y and y <= self.exit_rect.bottom): + return True + else: + return False + + def inAreaLittleGame(self, x, y): + if (x >= self.littleGame_rect.x and x <= self.littleGame_rect.right and y >= self.littleGame_rect.y and y <= self.littleGame_rect.bottom): + return True + else: + return False + + def checkHilight(self, x, y): + # 高亮冒险模式按钮 + if self.inAreaAdventure(x, y): + self.adventure_highlight_time = self.current_time + elif self.inAreaExit(x, y): + self.exit_highlight_time = self.current_time + elif self.inAreaLittleGame(x, y): self.littleGame_highlight_time = self.current_time def checkAdventureClick(self, mouse_pos): x, y = mouse_pos - if(x >= self.option_rect.x and x <= self.option_rect.right and - y >= self.option_rect.y and y <= self.option_rect.bottom): + if self.inAreaAdventure(x, y): self.option_clicked = True self.option_timer = self.option_start = self.current_time self.persist[c.LITTLEGAME_BUTTON] = False @@ -97,16 +114,14 @@ class Menu(tool.State): def checkExitClick(self, mouse_pos): x, y = mouse_pos # 这里检查范围应当拟合花瓶下部整个区域 - if(x >= self.exit_rect.x - 20 and x <= self.exit_rect.right + 20 and - y >= self.exit_rect.y - 5 and y <= self.exit_rect.bottom + 10): + if self.inAreaExit(x, y): self.done = True self.next = c.EXIT # 检查有没有按到小游戏 def checkLittleGameClick(self, mouse_pos): x, y = mouse_pos - if(x >= self.littleGame_rect.x and x <= self.littleGame_rect.right and - y >= self.littleGame_rect.y and y <= self.littleGame_rect.bottom): + if self.inAreaLittleGame(x, y): self.done = True # 确实小游戏还是用的level # 因为目前暂时没有生存模式和解谜模式,所以暂时设置为这样