进度
- 完善小推车
- 实现僵尸走到最左,先判断是否有小推车,若有触发小推车
- 小推车继承精灵类,对沿途僵尸进行碰撞杀死
- 实现小推车的移动画面
- 当僵尸走到最左,若无小推车,僵尸胜利,播放玩家失败音乐
class LawnCleaner(pygame.sprite.Sprite):
runspeed = 1
def __init__(self, screen, arow):
super().__init__()
self.image_surf = pygame.image.load('assets/LawnCleaner.png')
self.screen = screen
self.pos = pygame.math.Vector2(0, Benchmark[1] + arow * Cell[1])
self.rect = [40, 60, 50, 40]
self.car_status = 'ready'
def killzbs(self, zbq):
if not zbq.isEmpty():
headzp = zbq.head()
if self.pos.x < headzp.pos.x < self.pos.x + 100:
zbq.pop()
def run(self):
self.pos.x += self.runspeed
def update(self, zbq):
if self.car_status == 'run':
self.run()
self.killzbs(zbq)
if self.pos.x > Benchmark[2]:
self.car_status = 'used'
elif self.car_status == 'used':
return
self.screen.blit(self.image_surf, self.pos)
效果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b363f851228b926bfc9e09b5373f5cb7.gif#pic_center)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9c081ddabb2bc5519f683ecd0688a1cf.gif#pic_center)