Shoot actor, by itself, is quite basic; it only requires a
speed attribute and overrides the
update method so that the object is moved by the distance determined by this speed and the elapsed time between frames:
class Shoot(Actor): def __init__(self, x, y, img='img/shoot.png'): super(Shoot, self).__init__(img, x, y) self.speed = eu.Vector2(0, -400) def update(self, elapsed): self.move(self.speed * elapsed)
PlayerShoot class requires a bit more logic, since the player cannot shoot until the previous beam has hit an enemy or reached the end of the screen.
As we want to avoid global variables, we will use a class attribute to hold the reference to the current shot. When the shot leaves the scene, this reference will be set to ...