def creat(self, position, rotation, speed): image = pyglet.resource.image('bullet_205px_1235397_easyicon.net.png') sprite = Sprite(image, position=position, rotation=rotation, scale=0.03) self.add(sprite) length = HEIGHT - sprite.position[ 1] if rotation == 0 else -sprite.position[1] action = MoveBy((0, length), duration=abs(length) / speed) action.stop = lambda: self.remove(sprite) sprite.do(action)
def creat(self): image = pyglet.resource.image( 'airplane_625px_1234720_easyicon.net.png') sprite = Sprite(image, (randint(24, WIDTH - 24), HEIGHT), rotation=180, scale=0.1) sprite.health = 5 self.add(sprite) fire = Repeat(Delay(0.5) + CallFunc(self.fire, sprite)) sprite.do(fire) length = -sprite.position[1] move = MoveBy((0, length), duration=abs(length) / (200 / 1)) move.stop = lambda: self.remove(sprite) sprite.do(move)