Exemplo n.º 1
0
class DestroyAfter(Component):
    def __init__(self, milliseconds):
        super(DestroyAfter, self).__init__()
        self.__life_timer = Timer(milliseconds)
        
    def update(self, milliseconds=0):
        super(DestroyAfter, self).update(milliseconds)
            
        if self.__life_timer.is_time_up():
            self.__life_timer.reset()
            self.game_object.remove()
Exemplo n.º 2
0
class EndGameAfter(Component):
    def __init__(self, milliseconds=0):
        super(EndGameAfter, self).__init__()
        self.__life_timer = Timer(milliseconds)
        
    def update(self, milliseconds=0):
        super(EndGameAfter, self).update(milliseconds)
        
        if self.__life_timer.is_time_up():
            pygame.event.post(pygame.event.Event(pygame.locals.QUIT))
Exemplo n.º 3
0
 def __init__(self, image, lifetime):
     super(Particle, self).__init__(image)
     self.lifetime = Timer(int(lifetime))
     self.__velocity = Vector2D.from_angle(random.randrange(80.0, 100.0)) * -1.65
     
     sheet = ImageSheet(ResourceLoader.load('data//puffs.png'), (32, 32))
     
     puff = [(sheet[0], int(lifetime * 0.1)),
             (sheet[1], int(lifetime * 0.15)),
             (sheet[2], int(lifetime * 0.3)),
             (sheet[3], int(lifetime * 2.0))]
     
     self.animation = Animation('puff', puff)
     self.add(self.animation)
Exemplo n.º 4
0
class Particle(Sprite):
    def __init__(self, image, lifetime):
        super(Particle, self).__init__(image)
        self.lifetime = Timer(int(lifetime))
        self.__velocity = Vector2D.from_angle(random.randrange(80.0, 100.0)) * -1.65
        
        sheet = ImageSheet(ResourceLoader.load('data//puffs.png'), (32, 32))
        
        puff = [(sheet[0], int(lifetime * 0.1)),
                (sheet[1], int(lifetime * 0.15)),
                (sheet[2], int(lifetime * 0.3)),
                (sheet[3], int(lifetime * 2.0))]
        
        self.animation = Animation('puff', puff)
        self.add(self.animation)
        
    def update(self, milliseconds=0):
        super(Particle, self).update(milliseconds)
        
        self.position += self.__velocity * (milliseconds / 1000.0) * 60
        
        if self.lifetime.is_time_up():
            self.lifetime.reset()
            self.remove()
Exemplo n.º 5
0
 def __init__(self, milliseconds):
     super(DestroyAfter, self).__init__()
     self.__life_timer = Timer(milliseconds)
Exemplo n.º 6
0
 def __init__(self, milliseconds=0):
     super(EndGameAfter, self).__init__()
     self.__life_timer = Timer(milliseconds)