forked from zhiyuan/Project1
修改为菜单列表
This commit is contained in:
1 parent
2c3e4f5e37
commit
0d5063838d
1 file changed
+27
-13
@@ -26,8 +26,8 @@ class MainMenuScene(BaseScene):
|
|||||||
# 设置字体
|
# 设置字体
|
||||||
font_file = os.path.join(data_path(),"Dymon-ShouXieTi.otf")
|
font_file = os.path.join(data_path(),"Dymon-ShouXieTi.otf")
|
||||||
self.font = pygame.font.Font(font_file,16)
|
self.font = pygame.font.Font(font_file,16)
|
||||||
# 文本
|
self.text_rect_list = []
|
||||||
self.game_info_text = self.font.render('同时按下Z和X开始游戏,按ESC退出', True, Color.white)
|
self.__init_text_list()
|
||||||
|
|
||||||
# 雨滴列表
|
# 雨滴列表
|
||||||
self.rain_max = 50
|
self.rain_max = 50
|
||||||
@@ -45,17 +45,8 @@ class MainMenuScene(BaseScene):
|
|||||||
print("我去,是通关秘籍!")
|
print("我去,是通关秘籍!")
|
||||||
self.switch_to_scene("EmptyScene")
|
self.switch_to_scene("EmptyScene")
|
||||||
|
|
||||||
# 显示提示文本
|
# 显示选项文本
|
||||||
screen_rect = self.screen.get_rect() # 获取屏幕矩形
|
self.__show_ui()
|
||||||
text_rect = self.game_info_text.get_rect() # 获取文本矩形
|
|
||||||
self.__show(text_rect, (0, 15))
|
|
||||||
text_rect.center = screen_rect.center # 将文本居中到屏幕
|
|
||||||
self.screen.blit(self.game_info_text, text_rect.topleft)
|
|
||||||
|
|
||||||
# 调试信息,debug模式下显示
|
|
||||||
self.__show(screen_rect)
|
|
||||||
self.__show(text_rect,(0,30))
|
|
||||||
self.__show(text_rect.center,(0,45))
|
|
||||||
|
|
||||||
# 雨滴坠落
|
# 雨滴坠落
|
||||||
self.rain_fall()
|
self.rain_fall()
|
||||||
@@ -104,6 +95,29 @@ class MainMenuScene(BaseScene):
|
|||||||
}
|
}
|
||||||
self.rain_list.append(rain)
|
self.rain_list.append(rain)
|
||||||
|
|
||||||
|
def __init_text_list(self):
|
||||||
|
# 文本
|
||||||
|
text_list = [
|
||||||
|
"开始游戏(Z和X)",
|
||||||
|
"退出游戏(ESC)",
|
||||||
|
]
|
||||||
|
# 转换为文本框
|
||||||
|
for text_str in text_list:
|
||||||
|
self.text_rect_list.append(self.font.render(text_str, True, Color.white))
|
||||||
|
|
||||||
|
def __show_ui(self):
|
||||||
|
"""
|
||||||
|
显示所有选项
|
||||||
|
"""
|
||||||
|
screen_rect = self.screen.get_rect() # 获取屏幕矩形
|
||||||
|
count = 0
|
||||||
|
for text in self.text_rect_list:
|
||||||
|
text_rect = text.get_rect() # 获取文本矩形
|
||||||
|
text_rect.centerx = screen_rect.centerx # 将文本居中到屏幕
|
||||||
|
text_rect.y = screen_rect.y + count * 2 * text_rect.height + screen_rect.centerx/2
|
||||||
|
self.screen.blit(text, text_rect.topleft)
|
||||||
|
count += 1
|
||||||
|
|
||||||
def init_rain(self, max_num):
|
def init_rain(self, max_num):
|
||||||
"""
|
"""
|
||||||
初始化雨滴列表,保存雨滴落点的坐标
|
初始化雨滴列表,保存雨滴落点的坐标
|
||||||
|
|||||||
Reference in new issue
Block a user