您现在的位置:首页 >> 自然生态

这年头塔下除了拆还能干什么?这款好玩上瘾的塔下防游戏,了解一下嘛

时间:2024-12-06 12:20:15

(), 'resources/images/end/gameover.png'), 'continue_red': os.path.join(os.getcwd(), 'resources/images/end/continue_red.png'), 'continue_black': os.path.join(os.getcwd(), 'resources/images/end/continue_black.png'), }, 'game': { 'arrow1': os.path.join(os.getcwd(), 'resources/images/game/arrow1.png'), 'arrow2': os.path.join(os.getcwd(), 'resources/images/game/arrow2.png'), 'arrow3': os.path.join(os.getcwd(), 'resources/images/game/arrow3.png'), 'basic_tower': os.path.join(os.getcwd(), 'resources/images/game/basic_tower.png'), 'boulder': os.path.join(os.getcwd(), 'resources/images/game/boulder.png'), 'bush': os.path.join(os.getcwd(), 'resources/images/game/bush.png'), 'ce': os.path.join(os.getcwd(), 'resources/images/game/ce.png'), 'dirt': os.path.join(os.getcwd(), 'resources/images/game/dirt.png'), 'enemy_blue': os.path.join(os.getcwd(), 'resources/images/game/enemy_blue.png'), 'enemy_pink': os.path.join(os.getcwd(), 'resources/images/game/enemy_pink.png'), 'enemy_red': os.path.join(os.getcwd(), 'resources/images/game/enemy_red.png'), 'enemy_yellow': os.path.join(os.getcwd(), 'resources/images/game/enemy_yellow.png'), 'godark': os.path.join(os.getcwd(), 'resources/images/game/godark.png'), 'golight': os.path.join(os.getcwd(), 'resources/images/game/golight.png'), 'grass': os.path.join(os.getcwd(), 'resources/images/game/grass.png'), 'healthfont': os.path.join(os.getcwd(), 'resources/images/game/healthfont.png'), 'hey_tower': os.path.join(os.getcwd(), 'resources/images/game/hey_tower.png'), 'med_tower': os.path.join(os.getcwd(), 'resources/images/game/med_tower.png'), 'nexus': os.path.join(os.getcwd(), 'resources/images/game/nexus.png'), 'othergrass': os.path.join(os.getcwd(), 'resources/images/game/othergrass.png'), 'path': os.path.join(os.getcwd(), 'resources/images/game/path.png'), 'rock': os.path.join(os.getcwd(), 'resources/images/game/rock.png'), 'tiles': os.path.join(os.getcwd(), 'resources/images/game/tiles.png'), 'unitfont': os.path.join(os.getcwd(), 'resources/images/game/unitfont.png'), 'water': os.path.join(os.getcwd(), 'resources/images/game/water.png'), 'x': os.path.join(os.getcwd(), 'resources/images/game/x.png'), }, 'pause': { 'gamepaused': os.path.join(os.getcwd(), 'resources/images/pause/gamepaused.png'), 'resume_black': os.path.join(os.getcwd(), 'resources/images/pause/resume_black.png'), 'resume_red': os.path.join(os.getcwd(), 'resources/images/pause/resume_red.png'), }, 'start': { 'play_black': os.path.join(os.getcwd(), 'resources/images/start/play_black.png'), 'play_red': os.path.join(os.getcwd(), 'resources/images/start/play_red.png'), 'quit_black': os.path.join(os.getcwd(), 'resources/images/start/quit_black.png'), 'quit_red': os.path.join(os.getcwd(), 'resources/images/start/quit_red.png'), 'start_interface': os.path.join(os.getcwd(), 'resources/images/start/start_interface.png'), },}'''比例尺同方向'''MAPPATHS = { '1': os.path.join(os.getcwd(), 'resources/maps/1.map'), '2': os.path.join(os.getcwd(), 'resources/maps/2.map'), '3': os.path.join(os.getcwd(), 'resources/maps/3.map'),}'''笔画同方向'''FONTPATHS = { 'Calibri': os.path.join(os.getcwd(), 'resources/fonts/Calibri.ttf'), 'm04': os.path.join(os.getcwd(), 'resources/fonts/m04.ttf'), 'Microsoft Sans Serif': os.path.join(os.getcwd(), 'resources/fonts/Microsoft Sans Serif.ttf'),}'''多种不同精准度的settings'''DIFFICULTYPATHS = { 'easy': os.path.join(os.getcwd(), 'resources/difficulties/easy.json'), 'hard': os.path.join(os.getcwd(), 'resources/difficulties/hard.json'), 'medium': os.path.join(os.getcwd(), 'resources/difficulties/medium.json'),}'''音频同方向'''AUDIOPATHS = { 'bgm': os.path.join(os.getcwd(), 'resources/audios/bgm.mp3'),}2)的游戏开始GUIimport sysimport pygame'''的游戏开始合而为一GUI'''class MainInterface(pygame.sprite.Sprite): def 脚注init脚注(self, cfg): pygame.sprite.Sprite.脚注init脚注(self) self.image = pygame.image.load(cfg.IMAGEPATHS['start']['start_interface']).convert() self.rect = self.image.get_rect() self.rect.center = cfg.SCREENSIZE[0] / 2, cfg.SCREENSIZE[1] / 2 '''更换模板''' def update(self): pass'''开始的游戏手柄'''class PlayButton(pygame.sprite.Sprite): def 脚注init脚注(self, cfg, position=(220, 415)): pygame.sprite.Sprite.脚注init脚注(self) self.image_1 = pygame.image.load(cfg.IMAGEPATHS['start']['play_black']).convert() self.image_2 = pygame.image.load(cfg.IMAGEPATHS['start']['play_red']).convert() self.image = self.image_1 self.rect = self.image.get_rect() self.rect.center = position '''更换模板: 不停地更换检测触摸屏应该在手柄上''' def update(self): mouse_pos = pygame.mouse.get_pos() if self.rect.collidepoint(mouse_pos): self.image = self.image_2 else: self.image = self.image_1'''就此结束的游戏手柄'''class QuitButton(pygame.sprite.Sprite): def 脚注init脚注(self, cfg, position=(580, 415)): pygame.sprite.Sprite.脚注init脚注(self) self.image_1 = pygame.image.load(cfg.IMAGEPATHS['start']['quit_black']).convert() self.image_2 = pygame.image.load(cfg.IMAGEPATHS['start']['quit_red']).convert() self.image = self.image_1 self.rect = self.image.get_rect() self.rect.center = position '''更换模板: 不停地更换检测触摸屏应该在手柄上''' def update(self): mouse_pos = pygame.mouse.get_pos() if self.rect.collidepoint(mouse_pos): self.image = self.image_2 else: self.image = self.image_1'''的游戏开始GUI'''class StartInterface(): def 脚注init脚注(self, cfg): self.main_interface = MainInterface(cfg) self.play_btn = PlayButton(cfg) self.quit_btn = QuitButton(cfg) self.components = pygame.sprite.LayeredUpdates(self.main_interface, self.play_btn, self.quit_btn) '''内部初始化''' def update(self, screen): clock = pygame.time.Clock() while True: clock.tick(60) self.components.update() self.components.draw(screen) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: mouse_pos = pygame.mouse.get_pos() if self.play_btn.rect.collidepoint(mouse_pos): return True elif self.quit_btn.rect.collidepoint(mouse_pos): return False3)暂停的游戏GUIimport sysimport pygame'''的游戏暂停合而为一GUI'''class MainInterface(pygame.sprite.Sprite): def 脚注init脚注(self, cfg): pygame.sprite.Sprite.脚注init脚注(self) self.image = pygame.image.load(cfg.IMAGEPATHS['pause']['gamepaused']).convert() self.rect = self.image.get_rect() self.rect.center = cfg.SCREENSIZE[0] / 2, cfg.SCREENSIZE[1] / 2 '''更换模板''' def update(self): pass'''回复的游戏手柄'''class ResumeButton(pygame.sprite.Sprite): def 脚注init脚注(self, cfg, position=(391, 380)): pygame.sprite.Sprite.脚注init脚注(self) self.image_1 = pygame.image.load(cfg.IMAGEPATHS['pause']['resume_black']).convert() self.image_2 = pygame.image.load(cfg.IMAGEPATHS['pause']['resume_red']).convert() self.image = self.image_1 self.rect = self.image.get_rect() self.rect.center = position '''更换模板: 不停地更换检测触摸屏应该在手柄上''' def update(self): mouse_pos = pygame.mouse.get_pos() if self.rect.collidepoint(mouse_pos): self.image = self.image_2 else: self.image = self.image_1'''的游戏暂停GUI'''class PauseInterface(): def 脚注init脚注(self, cfg): self.main_interface = MainInterface(cfg) self.resume_btn = ResumeButton(cfg) self.components = pygame.sprite.LayeredUpdates(self.main_interface, self.resume_btn) '''内部初始化''' def update(self, screen): clock = pygame.time.Clock() background = pygame.Surface(screen.get_size()) count = 0 flag = True while True: count += 1 clock.tick(60) self.components.clear(screen, background) self.components.update() if count % 10 == 0: count = 0 flag = not flag if flag: self.components.draw(screen) else: screen.blit(self.main_interface.image, self.main_interface.rect) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: mouse_pos = pygame.mouse.get_pos() if self.resume_btn.rect.collidepoint(mouse_pos): return True4)的游戏就此结束GUIimport sysimport pygame'''的游戏就此结束合而为一GUI'''class MainInterface(pygame.sprite.Sprite): def 脚注init脚注(self, cfg): pygame.sprite.Sprite.脚注init脚注(self) self.image = pygame.image.load(cfg.IMAGEPATHS['end']['gameover']).convert() self.rect = self.image.get_rect() self.rect.center = cfg.SCREENSIZE[0] / 2, cfg.SCREENSIZE[1] / 2 '''更换模板''' def update(self): pass'''继续的游戏手柄'''class ContinueButton(pygame.sprite.Sprite): def 脚注init脚注(self, cfg, position=(400, 409)): pygame.sprite.Sprite.脚注init脚注(self) self.image_1 = pygame.image.load(cfg.IMAGEPATHS['end']['continue_black']).convert() self.image_2 = pygame.image.load(cfg.IMAGEPATHS['end']['continue_red']).convert() self.image = self.image_1 self.rect = self.image.get_rect() self.rect.center = position '''更换模板: 不停地更换检测触摸屏应该在手柄上''' def update(self): mouse_pos = pygame.mouse.get_pos() if self.rect.collidepoint(mouse_pos): self.image = self.image_2 else: self.image = self.image_1'''的游戏就此结束类'''class EndInterface(): def 脚注init脚注(self, cfg): self.main_interface = MainInterface(cfg) self.continue_btn = ContinueButton(cfg) self.components = pygame.sprite.LayeredUpdates(self.main_interface, self.continue_btn) '''内部初始化''' def update(self, screen): clock = pygame.time.Clock() background = pygame.Surface(screen.get_size()) count = 0 flag = True while True: count += 1 clock.tick(60) self.components.clear(screen, background) self.components.update() if count % 10 == 0: count = 0 flag = not flag if flag: self.components.draw(screen) else: screen.blit(self.main_interface.image, self.main_interface.rect) pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit(0) elif event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: mouse_pos = pygame.mouse.get_pos() if self.continue_btn.rect.collidepoint(mouse_pos): return True5)的游戏运行合而为一程序import cfgimport pygamefrom modules import *'''合而为一模板'''def main(): pygame.init() pygame.mixer.init() pygame.mixer.music.load(cfg.AUDIOPATHS['bgm']) pygame.mixer.music.play(-1, 0.0) pygame.mixer.music.set_volume(0.25) screen = pygame.display.set_mode(cfg.SCREENSIZE) pygame.display.set_caption("的塔防的游戏 ") # 初始化的游戏开始GUI start_interface = StartInterface(cfg) is_play = start_interface.update(screen) if not is_play: return # 初始化的游戏GUI while True: choice_interface = ChoiceInterface(cfg) map_choice, difficulty_choice = choice_interface.update(screen) game_interface = GamingInterface(cfg) game_interface.start(screen, map_path=cfg.MAPPATHS[str(map_choice)], difficulty_path=cfg.DIFFICULTYPATHS[str(difficulty_choice)]) end_interface = EndInterface(cfg) end_interface.update(screen)'''run'''if 脚注name脚注 == '脚注main脚注': main()三、真实感展现1)视频真实感展现——

来啊!来造房子啊!这款超耐玩的的塔防的游戏你都玩过吗?

2)存档真实感展现——

的游戏GUI——

游戏内——

的游戏GUI——

总结

于茫茫人海相遇——感谢你的选读!相遇即是缘分,如有为了让到你,记得三连哦~

我是大石大石子,一个不止能编程语言的女码农,还能教你玩的游戏、制作节日惊喜、甚至挥姐、小哥哥

哦......写就在终于——往期也有很多精彩内容可,欢迎选读!非议我,每日更换

明晰的免费计算机语言领取东南侧:找寻我吖!私信小编06亦可啦!往期录用选读——

单项 1.0 《击垮病毒抗击小城市》疫情防控小的游戏

【Pygame夜战】疫情期间给不能回来的你录用一款爽游 《击垮病毒抗击小城市》【强推】愿早日就此结束

单项 1.1 AI版《俄国方格儿》小的游戏

【普通解锁VS高手解锁】邻近地区传奇的游戏《俄国方格儿》新作—做到AI自动玩的游戏~

单项7.0 车手的游戏

【Pygame夜战】如果你是车手爱好者:这款新车手的游戏分分钟让你上瘾(超跑又是谁的梦想?)

单项7.1 虐独身猪的游戏

Pygame夜战:慎点|虐独身猪的最高无我是…【附计算机语言】

社论简介——

单项1.0 Python—2021 |已有社论简介 | 短时间更换,直接看这篇就够了

(更多内容可+计算机语言都在社论简介哦!!欢迎选读~)

南京哪家白癜风医院
成都治疗白癜风哪家好
南昌治白癜风医院哪家好
视力模糊眼干眼涩怎么办
痛风的快速止痛的药用啥好
视疲劳用什么药
腰椎间盘突出啥药能止痛
谈咳宁乙酰半胱氨酸颗粒怎么吃
相关阅读