一、子弹方法
增添:\bullet.py:
def update(self):
"""向上移动子弹"""
self.y -= self.speed_factor
self.rect.y = self.y
def draw_bullet(self):
"""在屏幕上绘制子弹"""
pygame.draw.rect(self.screen, self.color, self.rect)
二、子弹编组
更新:\FatChickenWars.py:
...
from pygame.sprite import Group
...
# 创建一只肥鸡
chicken = Chicken(screen, fcw_settings)
# 创建子弹编组
bullets = Group()
...
# 更新肥鸡状态
chicken.update()
# 更新子弹状态
bullets.update()
...
2021.1.21