def enemy_shoot(hero, shots): if hero.weapon.ammo > 0 and hero.shoot_count < 0: x, y, = hero.rect.center y1 = -6 s = True shoots = [] hero.weapon.sound.play() if hero.direction: s = Shot((x + 100, y + y1), (x + hero.wx_l, y + y1), hero.weapon.hit) if hero.weapon.bullet_num != 1: for i in range(hero.weapon.bullet_num): shoot = Shot((x + 100, y - 20 + 10 * i), (x + hero.wx_l, y + y1), hero.weapon.hit) shoot.image = pygame.image.load('bullit_r.png').convert() shoots.append(shoot) s.image = pygame.image.load('bullit_r.png').convert() else: s = Shot((x - 100, y + y1), (x + hero.wx_r, y + y1), hero.weapon.hit) if hero.weapon.bullet_num != 1: for i in range(hero.weapon.bullet_num): shoots.append(Shot((x - 100, y - 20 + 10 * i), (x + hero.wx_r, y + y1), hero.weapon.hit)) if type(s) == Shot: hero.weapon.shoot() hero.shoot_count = 50 shots.append(s) if shoots != []: shots += shoots return True else: return False