예제 #1
0
    def __init__(self, x, y, direction):
        self.x, self.y = (x, y)
        self.direction = direction
        if direction < 0: self.speed = -800
        else: self.speed = 800

        self.emitter = emitter.StaticEmitter(
          rate=300,
          template=Particle(
              position=(x, y, 0),
              velocity=(0, 0, 0),
              color=(1, 1, 0, 0.5),
              size=(8, 8, 0),
              # rotation?
              # up?
          ),
          velocity=Disc((0,0,0), (0,0,1), 200),
          time_to_live=self.duration,
        )
        self.fader = controller.Fader(start_alpha=1,fade_out_start=0,fade_out_end=.5,end_alpha=0)

        self.group = ParticleGroup(
            controllers=[
                self.emitter,
                controller.Gravity((0, -100, 0)),
                controller.Movement(),
                self.fader,
                controller.Lifetime(1),
            ],
            renderer=Render('zap-star.png'),
        )
        self.emitter.emit(1, self.group)
예제 #2
0
 def __init__(self, x, y, size):
     self.emitter = emitter.StaticEmitter(
         template = Particle(
             position=(x, y, 0),
             color=(1, 1, 1, .01),
             velocity=(0, 0, 0),
             size=(64, 64, 0),
         ),
         velocity=Disc((0,0,0), (0,0,1), 400),
     )
     self.group = ParticleGroup(
         controllers=[
             self.emitter,
             controller.Growth(50),
             controller.Movement(),
             controller.Fader(start_alpha=1,fade_out_start=0,fade_out_end=.7,end_alpha=0),
             controller.Lifetime(.7),
         ],
         renderer = Render('point64.png'),
     )
     self.emitter.emit(50, self.group)
예제 #3
0
 def __init__(self, rect, scale=1):
     x, y = rect.center
     self.emitter = emitter.StaticEmitter(
         rate = 20,
         template = Particle(
             position=(x, y, 0),
             color=(1, 1, 1, .5),
             velocity=(0, 0, 0),
             size=(8, 8, 0),
         ),
         velocity=Disc((0,0,0), (0,0,1), rect.width*.75*scale),
     )
     self.group = ParticleGroup(
         controllers=[
             self.emitter,
             controller.Movement(),
             controller.Clumper(50),
             controller.Fader(start_alpha=1,fade_out_start=0,fade_out_end=1,end_alpha=0),
             controller.Lifetime(1),
         ],
         renderer = Render(self.filename),
     )
     self.emitter.emit(1, self.group)
예제 #4
0
 def __init__(self, x1, y1, x2, y2):
     self.emitter = emitter.StaticEmitter(
         rate = (x2-x1) // 5,
         template = Particle(
             position=(x1, y1, 0),
             color=(1, 1, 1, .5),
             velocity=(0, 0, 0),
             size=(32, 32, 0),
         ),
         position=Line((x1, y1, 0), (x2, y1, 0)),
         velocity=AABox((-100, -50, 0), (100, -200, 1)),
     )
     self.group = ParticleGroup(
         controllers=[
             self.emitter,
             controller.Movement(),
             controller.Growth(100),
             controller.Gravity((0, -50, 0)),
             controller.Fader(start_alpha=1,fade_out_start=0,fade_out_end=1,end_alpha=0),
             controller.Lifetime(2),
         ],
         renderer = Render('black-bubble.png'),
     )
     self.emitter.emit(1, self.group)
예제 #5
0
# Actors should define emitters; the world will spawn these
particles = ParticleSystemNode()


def load(name):
    return pyglet.resource.texture(name)


wake_particles = particles.create_group(
    controllers=[
        #        Drag(0.1, 0.0, (0, 0, 0)),
        controller.Movement(),
        controller.Lifetime(5),
        controller.Fader(start_alpha=0.0,
                         max_alpha=0.3,
                         end_alpha=0.0,
                         fade_in_end=0.2,
                         fade_out_start=0.3,
                         fade_out_end=5.0)
    ],
    texture=load('foam.png'))

smoke_particles = particles.create_group(controllers=[
    controller.Movement(),
    controller.Lifetime(8),
    controller.Fader(start_alpha=0.0,
                     max_alpha=0.2,
                     end_alpha=0.0,
                     fade_in_end=0.0,
                     fade_out_start=0.5,
                     fade_out_end=8.0),
    controller.Growth(growth=2, )
예제 #6
0
# We should now be able to define all the particle engine stuff
# without code changes to the rest of the game
exhaust = load_texture('exhaust.png')

exhaust_particles = ParticleGroup(
    controllers=[
        controller.Movement(),
        controller.Lifetime(1),
        controller.ColorBlender([
            (0.0, (1.0, 0.3, 0.3, 0.3)),
            (0.2, (1.0, 0.8, 0.3, 0.3)),
            (0.5, (1.0, 1.0, 1.0, 0.2)),
            (1.0, (1.0, 1.0, 1.0, 0.0)),
        ]),
        controller.Growth(-3)
    ],
    renderer=BillboardRenderer(SpriteTexturizer(exhaust.id)),
)

explosion_particles = ParticleGroup(
    controllers=[
        controller.Movement(),
        controller.Lifetime(2),
        controller.Fader(start_alpha=1,
                         fade_out_start=1,
                         fade_out_end=2,
                         end_alpha=0.0)
    ],
    renderer=BillboardRenderer(SpriteTexturizer(exhaust.id)),
)