更改倭瓜碰撞检测
This commit is contained in:
parent
5bc89e1b81
commit
2c140577a1
@ -780,6 +780,16 @@ class Squash(Plant):
|
|||||||
return True
|
return True
|
||||||
# 攻击状态
|
# 攻击状态
|
||||||
elif (self.state == c.ATTACK):
|
elif (self.state == c.ATTACK):
|
||||||
|
# 位置检测
|
||||||
|
# 僵尸在倭瓜右侧
|
||||||
|
if zombie.rect.x >= self.rect.x:
|
||||||
|
# 重叠15%判断为可以攻击
|
||||||
|
if (self.rect.right - zombie.rect.left >= 0.15*zombie.rect.width):
|
||||||
|
return True
|
||||||
|
# 僵尸在倭瓜右侧
|
||||||
|
else:
|
||||||
|
if (zombie.rect.right - self.rect.left >= 0.15*zombie.rect.width):
|
||||||
|
return True
|
||||||
# 碰撞检测
|
# 碰撞检测
|
||||||
if pg.sprite.collide_mask(zombie, self):
|
if pg.sprite.collide_mask(zombie, self):
|
||||||
return True
|
return True
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user