更改子弹生存时间

This commit is contained in:
星外之神 2022-07-31 10:46:02 +08:00
parent 76533796a3
commit afda2a02c8
2 changed files with 4 additions and 4 deletions

View File

@ -104,7 +104,7 @@ class Bullet(pg.sprite.Sprite):
if self.y_vel * (self.dest_y - self.rect.y) < 0:
self.rect.y = self.dest_y
self.rect.x += self.x_vel
if self.rect.x >= c.SCREEN_WIDTH + 60:
if self.rect.x >= c.SCREEN_WIDTH + 20:
self.kill()
elif self.state == c.EXPLODE:
if (self.current_time - self.explode_timer) > 250:
@ -206,7 +206,7 @@ class StarBullet(Bullet):
else:
self.rect.x -= 10
self.handleMapYPosition()
if ((self.rect.x > c.SCREEN_WIDTH + 60) or (self.rect.x < -60)
if ((self.rect.x > c.SCREEN_WIDTH + 20) or (self.rect.right < -20)
or (self.rect.y > c.SCREEN_HEIGHT) or (self.rect.y < 0)):
self.kill()
elif self.state == c.EXPLODE:
@ -322,7 +322,7 @@ class Plant(pg.sprite.Sprite):
if (zombie.name == c.SNORKELZOMBIE) and (zombie.frames == zombie.swim_frames):
return False
if (self.state != c.SLEEP and zombie.state != c.DIE and
self.rect.x <= zombie.rect.right and zombie.rect.left <= c.SCREEN_WIDTH):
self.rect.x <= zombie.rect.right and zombie.rect.x <= c.SCREEN_WIDTH):
return True
return False

View File

@ -15,8 +15,8 @@ class Zombie(pg.sprite.Sprite):
self.frame_num = len(self.frames)
self.image = self.frames[self.frame_index]
self.mask = pg.mask.from_surface(self.image)
self.rect = self.image.get_rect()
self.mask = pg.mask.from_surface(self.image)
self.rect.x = x
self.rect.bottom = y
# 大蒜换行移动像素值,< 0时向上= 0时不变> 0时向上