合并预览与点击的检查方式

This commit is contained in:
星外之神 2022-04-24 13:31:59 +08:00
parent d054279e3f
commit ecbb70d134

View File

@ -71,23 +71,40 @@ class Menu(tool.State):
self.option_timer = 0 self.option_timer = 0
self.option_clicked = False 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 if (x >= self.option_rect.x and x <= self.option_rect.right and
y >= self.option_rect.y and y <= self.option_rect.bottom): y >= self.option_rect.y and y <= self.option_rect.bottom):
self.adventure_highlight_time = self.current_time return True
elif (x >= self.exit_rect.x - 20 and x <= self.exit_rect.right + 20 and else:
y >= self.exit_rect.y - 5 and y <= self.exit_rect.bottom + 10): return False
self.exit_highlight_time = self.current_time
elif (x >= self.littleGame_rect.x and x <= self.littleGame_rect.right and 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): 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 self.littleGame_highlight_time = self.current_time
def checkAdventureClick(self, mouse_pos): def checkAdventureClick(self, mouse_pos):
x, y = mouse_pos x, y = mouse_pos
if(x >= self.option_rect.x and x <= self.option_rect.right and if self.inAreaAdventure(x, y):
y >= self.option_rect.y and y <= self.option_rect.bottom):
self.option_clicked = True self.option_clicked = True
self.option_timer = self.option_start = self.current_time self.option_timer = self.option_start = self.current_time
self.persist[c.LITTLEGAME_BUTTON] = False self.persist[c.LITTLEGAME_BUTTON] = False
@ -97,16 +114,14 @@ class Menu(tool.State):
def checkExitClick(self, mouse_pos): def checkExitClick(self, mouse_pos):
x, y = mouse_pos x, y = mouse_pos
# 这里检查范围应当拟合花瓶下部整个区域 # 这里检查范围应当拟合花瓶下部整个区域
if(x >= self.exit_rect.x - 20 and x <= self.exit_rect.right + 20 and if self.inAreaExit(x, y):
y >= self.exit_rect.y - 5 and y <= self.exit_rect.bottom + 10):
self.done = True self.done = True
self.next = c.EXIT self.next = c.EXIT
# 检查有没有按到小游戏 # 检查有没有按到小游戏
def checkLittleGameClick(self, mouse_pos): def checkLittleGameClick(self, mouse_pos):
x, y = mouse_pos x, y = mouse_pos
if(x >= self.littleGame_rect.x and x <= self.littleGame_rect.right and if self.inAreaLittleGame(x, y):
y >= self.littleGame_rect.y and y <= self.littleGame_rect.bottom):
self.done = True self.done = True
# 确实小游戏还是用的level # 确实小游戏还是用的level
# 因为目前暂时没有生存模式和解谜模式,所以暂时设置为这样 # 因为目前暂时没有生存模式和解谜模式,所以暂时设置为这样