""" Tools for dealing with weapons. """
+from pygame.surface import Surface
+from pygame.draw import circle
from pgzero.loaders import images, sounds
from .actors.animsurf import AnimatedSurfActor
from .util import safepath
if self.sound:
self.sound.play()
+ def assemble_bullet(self):
+ return BulletActor(self)
+
WEAPONS = [
Weapon("spit", damage=1, bullet_range=2, can_tape=False,
self.weapon = weapon
+class BulletActor(AnimatedSurfActor):
+ def __init__(self, weapon, **kw):
+ radius = min(weapon.damage * 5, 32)
+ surf = Surface((radius * 2, radius * 2))
+ surf.convert_alpha()
+ surf.fill((255, 255, 255, 0))
+ circle(surf, (255, 0, 255, 32), (radius, radius), radius)
+ frames = [surf]
+ super().__init__(frames=frames, **kw)
+ self.weapon = weapon
+
+
class WeaponFactory:
def assemble_frame(self, suffix, weapon, tape):