From d93acfe9e38796fca356c5117e92531234e9cab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Fri, 5 Aug 2022 14:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D4-1=E5=85=B3=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/map.py | 4 ++-- source/state/level.py | 30 +++++++++++++++++------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/source/component/map.py b/source/component/map.py index 298cf58..ce01487 100755 --- a/source/component/map.py +++ b/source/component/map.py @@ -342,14 +342,14 @@ LEVEL_MAP_DATA = ( }, # 第13关 目前为浓雾第一关 尚未完善 { - c.BACKGROUND_TYPE: 2, + c.BACKGROUND_TYPE: 3, c.GAME_TITLE: "浓雾 4-1", c.INIT_SUN_NAME: 50, c.SHOVEL: 1, c.SPAWN_ZOMBIES:c.SPAWN_ZOMBIES_AUTO, c.INCLUDED_ZOMBIES: ( c.NORMAL_ZOMBIE, c.NEWSPAPER_ZOMBIE, c.ZOMBONI, c.FOOTBALL_ZOMBIE, - c.CONEHEAD_ZOMBIE, c.BUCKETHEAD_HEALTH), + c.CONEHEAD_ZOMBIE, c.BUCKETHEAD_ZOMBIE), c.NUM_FLAGS:4 }, ) diff --git a/source/state/level.py b/source/state/level.py index 74fa7b4..6091cf6 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -96,7 +96,7 @@ class Level(tool.State): # 改用列表生成器直接生成内容,不再在这里使用for循环 self.plant_groups = [pg.sprite.Group() for i in range(self.map_y_len)] self.zombie_groups = [pg.sprite.Group() for i in range(self.map_y_len)] - self.hypno_zombie_groups = [pg.sprite.Group() for i in range(self.map_y_len)] #zombies who are hypno after eating hypnoshroom + self.hypno_zombie_groups = [pg.sprite.Group() for i in range(self.map_y_len)] # 被魅惑的僵尸 self.bullet_groups = [pg.sprite.Group() for i in range(self.map_y_len)] @@ -159,7 +159,6 @@ class Level(tool.State): zombie_list.append(new_zombie) zombie_volume -= c.CREATE_ZOMBIE_DICT[new_zombie][0] waves.append(zombie_list) - # print(wave, zombie_list, len(zombie_list)) self.waves = waves @@ -183,13 +182,13 @@ class Level(tool.State): unoccupied = [] occupied = [] # 毁灭菇坑与冰道应当特殊化 - exceptionObjects = {c.HOLE, c.ICEFROZENPLOT} + exception_objects = {c.HOLE, c.ICEFROZENPLOT} # 遍历能生成墓碑的区域 for map_y in range(0, 4): for map_x in range(4, 8): # 为空、为毁灭菇坑、为冰道时看作未被植物占据 if ((not self.map.map[map_y][map_x][c.MAP_PLANT]) or - (all((i in exceptionObjects) for i in self.map.map[map_y][map_x][c.MAP_PLANT]))): + (all((i in exception_objects) for i in self.map.map[map_y][map_x][c.MAP_PLANT]))): unoccupied.append((map_x, map_y)) # 已有墓碑的格子不应该放到任何列表中 elif c.GRAVE not in self.map.map[map_y][map_x][c.MAP_PLANT]: @@ -209,7 +208,7 @@ class Level(tool.State): checkMapX, _ = self.map.getMapIndex(i.rect.centerx, i.rect.bottom) if map_x == checkMapX: # 不杀死毁灭菇坑和冰道 - if i.name not in exceptionObjects: + if i.name not in exception_objects: i.health = 0 self.plant_groups[map_y].add(plant.Grave(posX, posY)) self.map.map[map_y][map_x][c.MAP_PLANT].add(c.GRAVE) @@ -1548,14 +1547,6 @@ class Level(tool.State): self.showAllContentOfMenu(surface) # 以后可能需要插入一个预备的状态(预览显示僵尸、返回战场) elif self.state == c.PLAY: - if self.has_shovel: - # 画铲子 - surface.blit(self.shovel_box, self.shovel_box_rect) - surface.blit(self.shovel, self.shovel_rect) - # 画小菜单 - surface.blit(self.little_menu, self.little_menu_rect) - - self.menubar.draw(surface) for i in range(self.map_y_len): self.plant_groups[i].draw(surface) self.zombie_groups[i].draw(surface) @@ -1565,6 +1556,19 @@ class Level(tool.State): if self.cars[i]: self.cars[i].draw(surface) self.head_group.draw(surface) + + # 浓雾模式的雾 + #if self.background_type == c.BACKGROUND_FOG: + # pg.draw.rect(surface, c.LIGHTGRAY, (400, 0, 400, 600)) + + if self.has_shovel: + # 画铲子 + surface.blit(self.shovel_box, self.shovel_box_rect) + surface.blit(self.shovel, self.shovel_rect) + # 画小菜单 + surface.blit(self.little_menu, self.little_menu_rect) + + self.menubar.draw(surface) self.sun_group.draw(surface) if self.drag_plant: