diff --git a/source/state/level.py b/source/state/level.py index 5ac85f2..e0b859f 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -39,8 +39,12 @@ class Level(tool.State): def loadMap(self): if self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME: map_file = f'littleGame_{self.game_info[c.LITTLEGAME_NUM]}.json' + # 设置标题 + pg.display.set_caption(f"pypvz: 玩玩小游戏 第{self.game_info[c.LITTLEGAME_NUM]}关") elif self.game_info[c.GAME_MODE] == c.MODE_ADVENTURE: map_file = f'level_{self.game_info[c.LEVEL_NUM]}.json' + # 设置标题 + pg.display.set_caption(f"pypvz: 冒险模式 第{self.game_info[c.LEVEL_NUM]}关") file_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources' , 'data', 'map', map_file) # 最后一关之后应该结束了 try: @@ -1506,17 +1510,6 @@ class Level(tool.State): # 画僵尸头 surface.blit(self.level_progress_zombie_head_image, self.level_progress_zombie_head_image_rect) - def showLevelInfo(self, surface): - fontPath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),'resources', 'freesansbold.ttf') - font = pg.font.Font(fontPath, 20) - if self.game_info[c.GAME_MODE] == c.MODE_ADVENTURE: - text_to_show = f"Adventure: {self.game_info[c.LEVEL_NUM]}th" - elif self.game_info[c.GAME_MODE] == c.MODE_LITTLEGAME: - text_to_show = f"Mini Games: {self.game_info[c.LITTLEGAME_NUM]}th" - msg_image = font.render(text_to_show, True, c.LIGHTYELLOW, c.NAVYBLUE) - msg_rect = msg_image.get_rect() - - surface.blit(msg_image, (410, 565), (0, 0, msg_rect.w, msg_rect.h)) def draw(self, surface): self.level.blit(self.background, self.viewport, self.viewport) @@ -1565,6 +1558,5 @@ class Level(tool.State): if self.map_data[c.SPAWN_ZOMBIES] == c.SPAWN_ZOMBIES_AUTO: self.showLevelProgress(surface) - self.showLevelInfo(surface) if self.current_time - self.showHugeWaveApprochingTime <= 2000: surface.blit(self.huge_wave_approching_image, self.huge_wave_approching_image_rect) diff --git a/source/state/mainmenu.py b/source/state/mainmenu.py index 9909787..6301f4e 100644 --- a/source/state/mainmenu.py +++ b/source/state/mainmenu.py @@ -14,6 +14,7 @@ class Menu(tool.State): self.game_info = persist self.setupBackground() self.setupOptions() + pg.display.set_caption(c.ORIGINAL_CAPTION) def setupBackground(self): frame_rect = (80, 0, 800, 600) diff --git a/source/state/screen.py b/source/state/screen.py index a08793e..0a32440 100644 --- a/source/state/screen.py +++ b/source/state/screen.py @@ -3,9 +3,10 @@ from .. import tool from .. import constants as c class Screen(tool.State): - def __init__(self): + def __init__(self, caption=c.ORIGINAL_CAPTION): tool.State.__init__(self) self.end_time = 3000 + self.caption = caption def startup(self, current_time, persist): self.start_time = current_time @@ -15,6 +16,7 @@ class Screen(tool.State): name = self.getImageName() self.setupImage(name) self.next = self.set_next_state() + pg.display.set_caption(self.caption) def getImageName(self): pass @@ -38,7 +40,7 @@ class Screen(tool.State): class GameVictoryScreen(Screen): def __init__(self): - Screen.__init__(self) + Screen.__init__(self, caption="pypvz: 战斗胜利!") def getImageName(self): return c.GAME_VICTORY_IMAGE @@ -48,7 +50,7 @@ class GameVictoryScreen(Screen): class GameLoseScreen(Screen): def __init__(self): - Screen.__init__(self) + Screen.__init__(self, caption="pypvz: 战斗失败!") def getImageName(self): return c.GAME_LOSE_IMAGE