修复僵尸状态检查bug;更改贴图位置;改变僵尸动画帧率;增加铲子导入检查;修复喷菇子弹有冰冻的bug

This commit is contained in:
星外之神 2022-04-13 23:16:19 +08:00
parent fa58f317cc
commit d495aef2f9
5 changed files with 16 additions and 25 deletions

View File

@ -3,7 +3,7 @@
"init_sun_value":5000, "init_sun_value":5000,
"shovel":1, "shovel":1,
"zombie_list":[ "zombie_list":[
{"time":1000, "map_y":2, "name":"Zombie"}, {"time":1000, "map_y":2, "name":"NewspaperZombie"},
{"time":60000, "map_y":2, "name":"Zombie"} {"time":60000, "map_y":2, "name":"Zombie"}
] ]
} }

View File

@ -136,7 +136,7 @@ class MenuBar():
self.rect.y = 0 self.rect.y = 0
self.sun_value = sun_value self.sun_value = sun_value
self.card_offset_x = 32 self.card_offset_x = 23
self.setupCards(card_list) self.setupCards(card_list)
def loadFrame(self, name): def loadFrame(self, name):

View File

@ -494,7 +494,7 @@ class PuffShroom(Plant):
def attacking(self): def attacking(self):
if (self.current_time - self.shoot_timer) > 1400: if (self.current_time - self.shoot_timer) > 1400:
self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 10, self.rect.y + 10, self.bullet_group.add(Bullet(self.rect.right, self.rect.y + 10, self.rect.y + 10,
c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, False))
self.shoot_timer = self.current_time self.shoot_timer = self.current_time
def canAttack(self, zombie): def canAttack(self, zombie):
@ -744,7 +744,7 @@ class ScaredyShroom(Plant):
def attacking(self): def attacking(self):
if (self.current_time - self.shoot_timer) > 1400: if (self.current_time - self.shoot_timer) > 1400:
self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y + 40, self.rect.y + 40, self.bullet_group.add(Bullet(self.rect.right - 15, self.rect.y + 40, self.rect.y + 40,
c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, True)) c.BULLET_MUSHROOM, c.BULLET_DAMAGE_NORMAL, False))
self.shoot_timer = self.current_time self.shoot_timer = self.current_time

View File

@ -89,7 +89,6 @@ class Zombie(pg.sprite.Sprite):
self.helmetType2 = False self.helmetType2 = False
if self.name == c.NEWSPAPER_ZOMBIE: if self.name == c.NEWSPAPER_ZOMBIE:
self.speed = 2.5 self.speed = 2.5
self.animate_interval = 300 # 因为加速了时间间隔要除以倍率,所以减小动画帧率
if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()): if (self.current_time - self.walk_timer) > (c.ZOMBIE_WALK_INTERVAL * self.getTimeRatio()):
self.walk_timer = self.current_time self.walk_timer = self.current_time
@ -107,6 +106,8 @@ class Zombie(pg.sprite.Sprite):
if self.helmetType2Health <= 0 and self.helmetType2: if self.helmetType2Health <= 0 and self.helmetType2:
self.changeFrames(self.attack_frames) self.changeFrames(self.attack_frames)
self.helmetType2 = False self.helmetType2 = False
if self.name == c.NEWSPAPER_ZOMBIE:
self.speed = 2.5
if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getAttackTimeRatio()): if (self.current_time - self.attack_timer) > (c.ATTACK_INTERVAL * self.getAttackTimeRatio()):
if self.prey.health > 0: if self.prey.health > 0:
if self.prey_is_plant: if self.prey_is_plant:
@ -134,8 +135,8 @@ class Zombie(pg.sprite.Sprite):
def setLostHead(self): def setLostHead(self):
self.losthead_timer = self.current_time self.losthead_timer = self.current_time
self.lostHead = True self.lostHead = True
self.animate_interval = 180
self.speed = 0.5 self.speed = 0.5
self.animate_interval = 180
if self.head_group is not None: if self.head_group is not None:
self.head_group.add(ZombieHead(self.rect.centerx, self.rect.bottom)) self.head_group.add(ZombieHead(self.rect.centerx, self.rect.bottom))
@ -204,12 +205,10 @@ class Zombie(pg.sprite.Sprite):
if self.helmetType2: if self.helmetType2:
self.helmetType2Health -= damage self.helmetType2Health -= damage
if self.helmetType2Health <= 0: if self.helmetType2Health <= 0:
self.helmetType2 = False
if self.helmet: if self.helmet:
self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负 self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负
self.helmetType2Health = 0 # 注意合并后清零 self.helmetType2Health = 0 # 注意合并后清零
if self.helmetHealth <= 0: if self.helmetHealth <= 0:
self.helmet = False
self.health += self.helmetHealth self.health += self.helmetHealth
self.helmetHealth = 0 # 注意合并后清零 self.helmetHealth = 0 # 注意合并后清零
else: else:
@ -218,7 +217,6 @@ class Zombie(pg.sprite.Sprite):
elif self.helmet: # 不存在二类防具,但是存在一类防具 elif self.helmet: # 不存在二类防具,但是存在一类防具
self.helmetHealth -= damage self.helmetHealth -= damage
if self.helmetHealth <= 0: if self.helmetHealth <= 0:
self.helmet = False
self.health += self.helmetHealth self.health += self.helmetHealth
self.helmetHealth = 0 # 注意合并后清零 self.helmetHealth = 0 # 注意合并后清零
else: # 没有防具 else: # 没有防具
@ -227,7 +225,6 @@ class Zombie(pg.sprite.Sprite):
if self.helmet: # 存在一类防具 if self.helmet: # 存在一类防具
self.helmetHealth -= damage self.helmetHealth -= damage
if self.helmetHealth <= 0: if self.helmetHealth <= 0:
self.helmet = False
self.health += self.helmetHealth self.health += self.helmetHealth
self.helmetHealth = 0 # 注意合并后清零 self.helmetHealth = 0 # 注意合并后清零
else: # 没有一类防具 else: # 没有一类防具
@ -237,13 +234,11 @@ class Zombie(pg.sprite.Sprite):
if self.helmetType2: if self.helmetType2:
self.helmetType2Health -= damage self.helmetType2Health -= damage
if self.helmetType2Health <= 0: if self.helmetType2Health <= 0:
self.helmetType2 = False
if self.helmet: if self.helmet:
self.helmetHealth -= damage # 注意范围伤害中这里还有一个攻击 self.helmetHealth -= damage # 注意范围伤害中这里还有一个攻击
self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负 self.helmetHealth += self.helmetType2Health # 注意self.helmetType2Health已经带有正负
self.helmetType2Health = 0 # 注意合并后清零 self.helmetType2Health = 0 # 注意合并后清零
if self.helmetHealth <= 0: if self.helmetHealth <= 0:
self.helmet = False
self.health += self.helmetHealth self.health += self.helmetHealth
self.helmetHealth = 0 # 注意合并后清零 self.helmetHealth = 0 # 注意合并后清零
else: else:
@ -253,7 +248,6 @@ class Zombie(pg.sprite.Sprite):
elif self.helmet: # 不存在二类防具,但是存在一类防具 elif self.helmet: # 不存在二类防具,但是存在一类防具
self.helmetHealth -= damage self.helmetHealth -= damage
if self.helmetHealth <= 0: if self.helmetHealth <= 0:
self.helmet = False
self.health += self.helmetHealth self.health += self.helmetHealth
self.helmetHealth = 0 # 注意合并后清零 self.helmetHealth = 0 # 注意合并后清零
else: # 没有防具 else: # 没有防具
@ -265,12 +259,8 @@ class Zombie(pg.sprite.Sprite):
# 以后增设铁门后可能需要设置侧面冲撞特殊性 # 以后增设铁门后可能需要设置侧面冲撞特殊性
if self.helmetType2: if self.helmetType2:
self.helmetType2Health -= damage self.helmetType2Health -= damage
if self.helmetType2Health <= 0:
self.helmetType2 = False
elif self.helmet: # 不存在二类防具,但是存在一类防具 elif self.helmet: # 不存在二类防具,但是存在一类防具
self.helmetHealth -= damage self.helmetHealth -= damage
if self.helmetHealth <= 0:
self.helmet = False
else: # 没有防具 else: # 没有防具
self.health -= damage self.health -= damage
else: else:
@ -307,7 +297,7 @@ class Zombie(pg.sprite.Sprite):
def setDie(self): def setDie(self):
self.state = c.DIE self.state = c.DIE
self.animate_interval = 100 self.animate_interval = 80
self.changeFrames(self.die_frames) self.changeFrames(self.die_frames)
def setBoomDie(self): def setBoomDie(self):

View File

@ -289,7 +289,8 @@ class Level(tool.State):
# 方便放回去 # 方便放回去
def checkShovelClick(self, mouse_pos): def checkShovelClick(self, mouse_pos):
x, y = mouse_pos x, y = mouse_pos
if(x >= self.shovel_box_rect.x and x <= self.shovel_box_rect.right and if( self.hasShovel and
x >= self.shovel_box_rect.x and x <= self.shovel_box_rect.right and
y >= self.shovel_box_rect.y and y <= self.shovel_box_rect.bottom): y >= self.shovel_box_rect.y and y <= self.shovel_box_rect.bottom):
return True return True
return False return False
@ -422,13 +423,11 @@ class Level(tool.State):
def createZombie(self, name, map_y=None): def createZombie(self, name, map_y=None):
# 有指定时按照指定生成,无指定时随机位置生成 # 有指定时按照指定生成,无指定时随机位置生成
# 0:白天 1:夜晚 2:泳池 3:浓雾 4:屋顶 5:月夜 # 0:白天 1:夜晚 2:泳池 3:浓雾 4:屋顶 5:月夜 6:坚果保龄球
if map_y == None: if map_y == None:
if self.map_data[c.BACKGROUND_TYPE] in {0, 1, 4, 5}:
map_y = randint(0, 4)
# 情况复杂:分水路和陆路,不能简单实现,需要另外加判断 # 情况复杂:分水路和陆路,不能简单实现,需要另外加判断
# 0, 1, 4, 5路为陆路2, 3路为水路 # 0, 1, 4, 5路为陆路2, 3路为水路
elif self.map_data[c.BACKGROUND_TYPE] in {2, 3}: if self.map_data[c.BACKGROUND_TYPE] in {2, 3}:
if name in {}: # 这里还没填,以后加了泳池模式填:水生僵尸集合 if name in {}: # 这里还没填,以后加了泳池模式填:水生僵尸集合
map_y = randint(2, 3) map_y = randint(2, 3)
elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)': elif name == '这里应该换成气球僵尸的名字(最好写调用的变量名,最好不要直接写,保持风格统一)':
@ -437,6 +436,8 @@ class Level(tool.State):
map_y = randint(0, 3) map_y = randint(0, 3)
if map_y >= 2: # 后两路的map_y应当+2 if map_y >= 2: # 后两路的map_y应当+2
map_y += 2 map_y += 2
else:
map_y = randint(0, 4)
# 新增的僵尸也需要在这里声明 # 新增的僵尸也需要在这里声明
x, y = self.map.getMapGridPos(0, map_y) x, y = self.map.getMapGridPos(0, map_y)
@ -588,7 +589,7 @@ class Level(tool.State):
if bullet.state == c.FLY: if bullet.state == c.FLY:
zombie = pg.sprite.spritecollideany(bullet, self.zombie_groups[i], collided_func) zombie = pg.sprite.spritecollideany(bullet, self.zombie_groups[i], collided_func)
if zombie and zombie.state != c.DIE: if zombie and zombie.state != c.DIE:
zombie.setDamage(bullet.damage, bullet.ice, damageType=c.ZOMBIE_DEAFULT_DAMAGE) zombie.setDamage(bullet.damage, ice=bullet.ice, damageType=c.ZOMBIE_DEAFULT_DAMAGE)
bullet.setExplode() bullet.setExplode()
def checkZombieCollisions(self): def checkZombieCollisions(self):