倭瓜改为双碰撞检测
This commit is contained in:
parent
e17c16927f
commit
6bc813ce8e
@ -780,18 +780,7 @@ class Squash(Plant):
|
||||
return True
|
||||
# 攻击状态
|
||||
elif (self.state == c.ATTACK):
|
||||
# 位置检测
|
||||
# 僵尸在倭瓜右侧
|
||||
if zombie.rect.x >= self.rect.x:
|
||||
# 重叠15%判断为可以攻击
|
||||
if (self.rect.right - zombie.rect.left >= 20):
|
||||
return True
|
||||
# 僵尸在倭瓜右侧
|
||||
else:
|
||||
if (zombie.rect.right - self.rect.left >= 20):
|
||||
return True
|
||||
# 碰撞检测
|
||||
if pg.sprite.collide_mask(zombie, self):
|
||||
if pg.sprite.collide_rect_ratio(0.5)(zombie, self) or pg.sprite.collide_mask(zombie, self):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user