From 1a54844ffe334fbd5f34ced0963c3377b3a15c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E5=A4=96=E4=B9=8B=E7=A5=9E?= Date: Tue, 7 Jun 2022 14:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/state/level.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/state/level.py b/source/state/level.py index 89005c6..d4d222d 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -93,15 +93,11 @@ class Level(tool.State): self.sun_group = pg.sprite.Group() self.head_group = pg.sprite.Group() - self.plant_groups = [] - self.zombie_groups = [] - self.hypno_zombie_groups = [] #zombies who are hypno after eating hypnoshroom - self.bullet_groups = [] - for i in range(self.map_y_len): - self.plant_groups.append(pg.sprite.Group()) - self.zombie_groups.append(pg.sprite.Group()) - self.hypno_zombie_groups.append(pg.sprite.Group()) - self.bullet_groups.append(pg.sprite.Group()) + # 改用列表生成器直接生成内容,不再在这里使用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.bullet_groups = [pg.sprite.Group() for i in range(self.map_y_len)] # 按照规则生成每一波僵尸