Skip to content

Commit

Permalink
更改倭瓜碰撞检测
Browse files Browse the repository at this point in the history
  • Loading branch information
wszqkzqk committed May 14, 2022
1 parent 5bc89e1 commit 2c14057
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions source/component/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,16 @@ def canAttack(self, zombie):
return True
# 攻击状态
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):
return True
Expand Down

0 comments on commit 2c14057

Please sign in to comment.