From 319610008ea4982a5785af391186561dc47daed9 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, 10 May 2022 23:52:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=92=91=E6=9D=86=E8=B7=B3?= =?UTF-8?q?=E5=83=B5=E5=B0=B8=E7=94=9F=E5=91=BD=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/component/zombie.py | 20 +++++++++++--------- source/constants.py | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/source/component/zombie.py b/source/component/zombie.py index 41f087e..814e60b 100755 --- a/source/component/zombie.py +++ b/source/component/zombie.py @@ -6,7 +6,7 @@ from .. import constants as c class Zombie(pg.sprite.Sprite): - def __init__(self, x, y, name, head_group=None, helmetHealth=0, helmetType2Health=0, bodyHealth=c.NORMAL_HEALTH + c.LOSTHEAD_HEALTH, damage=c.ZOMBIE_ATTACK_DAMAGE, canSwim=False): + def __init__(self, x, y, name, head_group=None, helmetHealth=0, helmetType2Health=0, bodyHealth=c.NORMAL_HEALTH, lostHeadHealth=c.LOSTHEAD_HEALTH, damage=c.ZOMBIE_ATTACK_DAMAGE, canSwim=False): pg.sprite.Sprite.__init__(self) self.name = name @@ -22,7 +22,8 @@ class Zombie(pg.sprite.Sprite): self.helmetHealth = helmetHealth self.helmetType2Health = helmetType2Health - self.health = bodyHealth + self.health = bodyHealth + lostHeadHealth + self.lostHeadHealth = lostHeadHealth self.damage = damage self.dead = False self.lostHead = False @@ -83,7 +84,7 @@ class Zombie(pg.sprite.Sprite): if self.health <= 0: self.setDie() return True - elif self.health <= c.LOSTHEAD_HEALTH: + elif self.health <= self.lostHeadHealth: if not self.lostHead: self.changeFrames(framesKind) self.setLostHead() @@ -848,7 +849,7 @@ class ScreenDoorZombie(Zombie): class PoleVaultingZombie(Zombie): def __init__(self, x, y, head_group): - Zombie.__init__(self, x, y, c.POLE_VAULTING_ZOMBIE, head_group=head_group) + Zombie.__init__(self, x, y, c.POLE_VAULTING_ZOMBIE, head_group=head_group, bodyHealth=c.POLE_VAULTING_HEALTH, lostHeadHealth=c.POLE_VAULTING_LOSTHEAD_HEALTH) self.speed = 1.88 self.jumped = False self.jumping = False @@ -900,11 +901,12 @@ class PoleVaultingZombie(Zombie): if (self.current_time - self.animate_timer) > (self.animate_interval * self.getTimeRatio()): self.frame_index += 1 - if self.jumping and (not self.jumped): - if self.successfullyJumped: - self.rect.x -= 5 - else: - self.rect.x -= 1 + if self.state == c.WALK: + if self.jumping and (not self.jumped): + if self.successfullyJumped: + self.rect.x -= 5 + else: + self.rect.x -= 1 if self.frame_index >= self.frame_num: if self.state == c.DIE: self.kill() diff --git a/source/constants.py b/source/constants.py index 87357ae..f12c384 100755 --- a/source/constants.py +++ b/source/constants.py @@ -328,6 +328,7 @@ ZOMBIE_WALLNUT_BOWLING_DANMAGE = 'wallnutBowlingDamage' # 坚果保龄球冲撞 LOSTHEAD_HEALTH = 70 NORMAL_HEALTH = 200 # 普通僵尸生命值 POLE_VAULTING_HEALTH = 333 +POLE_VAULTING_LOSTHEAD_HEALTH = 167 # 有关一类防具 CONEHEAD_HEALTH = 370 BUCKETHEAD_HEALTH = 1100