改用碰撞函数表示土豆雷攻击
This commit is contained in:
parent
4df085cf4c
commit
640059eb47
@ -593,7 +593,7 @@ class PotatoMine(Plant):
|
||||
self.is_init = True
|
||||
self.init_timer = 0
|
||||
self.bomb_timer = 0
|
||||
self.explode_x_range = c.GRID_X_SIZE
|
||||
self.explode_x_range = c.GRID_X_SIZE / 2
|
||||
|
||||
def loadImages(self, name, scale):
|
||||
self.init_frames = []
|
||||
@ -621,8 +621,8 @@ class PotatoMine(Plant):
|
||||
self.is_init = False
|
||||
|
||||
def canAttack(self, zombie):
|
||||
if (not self.is_init and (not zombie.lostHead) and
|
||||
(abs(zombie.rect.x - self.rect.x) <= self.explode_x_range*0.8)):
|
||||
if (pg.sprite.collide_circle_ratio(0.6)(zombie, self) and
|
||||
(not self.is_init) and (not zombie.lostHead)):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@ -1015,7 +1015,8 @@ class Level(tool.State):
|
||||
self.hypno_zombie_groups[map_y].add(zombie)
|
||||
elif (plant.name == c.POTATOMINE and not plant.is_init): # 土豆雷不是灰烬植物,不能用Boom
|
||||
for zombie in self.zombie_groups[map_y]:
|
||||
if ((abs(zombie.rect.centerx - x) <= plant.explode_x_range) or
|
||||
if ((pg.sprite.collide_circle_ratio(0.6)(zombie, plant)) or
|
||||
(abs(zombie.rect.centerx - x) <= plant.explode_x_range) or
|
||||
((zombie.rect.right - (x-plant.explode_x_range) > 20) or (zombie.rect.right - (x-plant.explode_x_range))/zombie.rect.width > 0.2, ((x+plant.explode_x_range) - zombie.rect.left > 20) or ((x+plant.explode_x_range) - zombie.rect.left)/zombie.rect.width > 0.2)[zombie.rect.x > x]): # 这代码不太好懂,后面是一个判断僵尸在左还是在右,前面是一个元组,[0]是在左边的情况,[1]是在右边的情况
|
||||
zombie.setDamage(1800, damageType=c.ZOMBIE_RANGE_DAMAGE)
|
||||
elif plant.name != c.WALLNUTBOWLING:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user