Ejemplo n.º 1
0
    def test_Growth_controller_simple(self):
        from lepton import controller
        group = self._make_group()

        # Simple growth, no damping
        growth = controller.Growth(1)
        growth(0.2, group)
        p = list(group)
        self.assertVector(p[0].size, (0.2, 0.2, 0.2))
        self.assertVector(p[1].size, (2.2, 2.2, 2.2))
        self.assertVector(p[2].size, (3.2, 2.2, 0.2))
Ejemplo n.º 2
0
    def test_Growth_controller_damping_vector(self):
        from lepton import controller
        group = self._make_group()

        # Growth w/damping vector
        growth = controller.Growth(growth=(2, 1, 0), damping=(1, 0.9, 0))
        growth(0.1, group)
        growth(0.1, group)
        p = list(group)
        self.assertVector(p[0].size, (0.4, 0.19, 0))
        self.assertVector(p[1].size, (2.4, 2.19, 2))
        self.assertVector(p[2].size, (3.4, 2.19, 0))
Ejemplo n.º 3
0
    def test_Growth_controller_damping_scalar(self):
        from lepton import controller
        group = self._make_group()

        # Growth w/damping
        growth = controller.Growth(growth=1, damping=0.9)
        growth(0.1, group)
        growth(0.1, group)
        p = list(group)
        self.assertVector(p[0].size, (0.19, 0.19, 0.19))
        self.assertVector(p[1].size, (2.19, 2.19, 2.19))
        self.assertVector(p[2].size, (3.19, 2.19, 0.19))
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 def load(cls):
     super(Rocket, cls).load()
     img = loader.image('data/sprites/rocket-spark.png')
     cls.particle_texture = img
     w = img.width
     h = img.height
     img.anchor_x = w * 0.5
     img.anchor_y = h * 0.5
     cls.particle_controllers = [
         controller.Movement(),
         controller.Lifetime(max_age=2),
         controller.Growth(30.0),
         controller.ColorBlender([
             (0, (1.0, 0.9, 0.0, 1.0)),
             (1, (0.0, 0.0, 0.0, 0.2)),
             (3, (0.0, 0.0, 0.0, 0.0)),
         ]),
         controller.Bounce(domain=domain.Plane((0, SEA_LEVEL, 0),
                                               (0, 1, 0)),
                           bounce=0.02)
     ]
     cls.particle_renderer = Renderer(cls.particle_texture)
Ejemplo n.º 6
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)
Ejemplo n.º 7
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, )
],
                                         texture=load('smoke.png'))

splinter_controllers = [
    controller.Movement(),
    controller.Lifetime(3),
    controller.Gravity((0, -2, 0)),
    controller.Collector(domain=domain.Plane((0, 0, 0), (0, 1, 0)))
]

splinters1 = particles.create_group(controllers=splinter_controllers,
                                    texture=load('splinter1.png'))
splinters2 = particles.create_group(controllers=splinter_controllers,
                                    texture=load('splinter2.png'))
Ejemplo n.º 8
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)),
)