Esempio n. 1
0
                                       color=(0.1, 0.1, 0.1)))

default_system.add_global_controller(
    Movement(max_velocity=10),
    Collector(viewer_plane),
    Gravity((0, 0, 15)),
    Growth(0.17),
    Fader(fade_in_end=0, max_alpha=0.3, fade_out_start=0, fade_out_end=8.0),
)

texture = image.load(os.path.join(os.path.dirname(__file__),
                                  'Particle.bmp')).get_texture()
group = ParticleGroup(controllers=[jet],
                      renderer=BillboardRenderer(SpriteTexturizer(texture.id)))

default_system.run_ahead(5, 40)

pyglet.clock.schedule_interval(default_system.update, (1.0 / 30.0))
pyglet.clock.set_fps_limit(None)
time = 0


def ring(dt):
    """Emit a ring of particles periodically"""
    jet.emit(1000, group)


pyglet.clock.schedule_interval(ring, 5)


def vary_radius(dt):
Esempio n. 2
0
        (0, (0, 0, 0.5, 0)),
        (0.5, (0, 0, 0.5, 0.2)),
        (0.75, (0, 0.5, 1, 0.6)),
        (1.5, (1, 1, 0, 0.2)),
        (2.7, (0.9, 0.2, 0, 0.4)),
        (3.2, (0.6, 0.1, 0.05, 0.2)),
        (4.0, (0.8, 0.8, 0.8, 0.1)),
        (6.0, (0.8, 0.8, 0.8, 0)),
    ]),
)

group = ParticleGroup(controllers=[flame],
                      renderer=PointRenderer(
                          64, SpriteTexturizer(create_point_texture(64, 5))))

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0 / 30.0))
pyglet.clock.set_fps_limit(None)


@win.event
def on_draw():
    win.clear()
    glLoadIdentity()
    default_system.draw()


if __name__ == '__main__':
    default_system.run_ahead(2, 30)
    pyglet.app.run()
Esempio n. 3
0
def init(lokumBorg=None):

    platform = pyglet.window.get_platform() 
    display = platform.get_default_display() 
    
    W = 200
    H = 200
    X = 0
    Y = 0
    screens = display.get_screens() 
    window = pyglet.window.Window(fullscreen=True, screen=screens[1])
    # window = pyglet.window.Window(width=W, height=H, resizable=True)
    # window = pyglet.window.Window(resizable=True, visible=False)
    win = window
    win.clear()
    console = Console(x=X, y=Y,width=W, height=H, window=window)

    @window.event
    def on_draw():
        glEnable(GL_BLEND)
        glShadeModel(GL_SMOOTH)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE)
        glDisable(GL_DEPTH_TEST)

        # glClearColor(1,1,1,1)
        glClearColor(1,0,0,1)
        window.clear()
        glLoadIdentity()
        default_system.draw()
        # player.get_texture().blit(100, 200,width=400,height=300)
        console.draw()


    @window.event
    def on_resize(width, height):
        console.resize(width,height)

    @console.event
    def on_command(command):
        global ANS,NBSEC
        if lokumBorg:
            ANS, dursec = lokumBorg.reply(command)
            if ANS: lokumBorg.save_line(ANS.strip())
            ANS = list(ANS)
            ANS.reverse()
            if dursec!=0:
                nblettres = len(ANS)
                NBSEC = float(dursec)/nblettres
                # set color for the borg
                console.write ('\n',attributes={'color': (0, 255, 0, 255)})
                clock.schedule_interval(callborg, NBSEC)

    console.prompt(" ")
    window.push_handlers(console)

    def callborg(dt):
        global ANS, NBSEC
        if ANS:
            c = ANS.pop()
            console.write(c)
            # time.sleep(NBSEC)
            console._caret.position = len(console._document.text)

        elif ANS==[]:
            console.write (' ',attributes={'color': (255, 255, 255, 120)})
            console.write ('\n')
            console.prompt()
            #console._document.delete_text(0, len(console._document.text)-1)
            #console._prompt_end = 0
            ANS = None
            clock.unschedule(callborg)
        else: ANS=None

    ### ---------- fire

    flame = StaticEmitter(
            rate=500,
            template=Particle(
                    position=(300,25,0), 
                    velocity=(0,0,0), 
                    color=(1,1,1,1),
            ),
            position=Line((win.width/2 - 85, -15, 0), (win.width/2 + 85, -15, 0)),
            deviation=Particle(position=(10,0,0), velocity=(7,50,0), age=0.75)
    )

    default_system.add_global_controller(
            Lifetime(6),
            Gravity((0,20,0)), 
            Movement(), 
            ColorBlender(
                    [(0, (0,0,0.5,0)), 
                    (0.5, (0,0,0.5,0.2)), 
                    (0.75, (0,0.5,1,0.6)), 
                    (1.5, (1,1,0,0.2)), 
                    (2.7, (0.9,0.2,0,0.4)), 
                    (3.2, (0.6,0.1,0.05,0.2)), 
                    (4.0, (0.8,0.8,0.8,0.1)),
                    (6.0, (0.8,0.8,0.8,0)), ]
            ),
    )


    group = ParticleGroup(controllers=[flame], 
            renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 5))))

    #win.set_visible(True)
    #win.set_visible(True)
    pyglet.clock.schedule_interval(default_system.update, (1.0/100.0))
    pyglet.clock.set_fps_limit(None)

    if 0:
        source = pyglet.media.load('/data/video/test.dv')
        format = source.video_format
        global player
        player = pyglet.media.Player()
        player.queue(source)
        player.play()


    default_system.run_ahead(2, 30)
    ### ------------- fire


    pyglet.app.run()
Esempio n. 4
0
		color=(0.1, 0.1, 0.1))
)

default_system.add_global_controller(
	Movement(max_velocity=10),
	Collector(viewer_plane),
	Gravity((0,0,15)),
	Growth(0.17),
	Fader(fade_in_end=0, max_alpha=0.3, fade_out_start=0, fade_out_end=8.0),
)

texture = image.load(os.path.join(os.path.dirname(__file__), 'Particle.bmp')).get_texture()
group = ParticleGroup(controllers=[jet], 
	renderer=BillboardRenderer(SpriteTexturizer(texture.id)))

default_system.run_ahead(5, 40)

pyglet.clock.schedule_interval(default_system.update, (1.0/30.0))
pyglet.clock.set_fps_limit(None)
time = 0

def ring(dt):
	"""Emit a ring of particles periodically"""
	jet.emit(1000, group)
pyglet.clock.schedule_interval(ring, 5)

def vary_radius(dt):
	"""Vary the disc radius over time"""
	global time
	time += dt
	disc.inner_radius = disc.outer_radius = 2.5 + math.sin(time / 2.0) * 1.5
Esempio n. 5
0
	Gravity((0,20,0)), 
	Movement(), 
	ColorBlender(
		[(0, (0,0,0.5,0)), 
		(0.5, (0,0,0.5,0.2)), 
		(0.75, (0,0.5,1,0.6)), 
		(1.5, (1,1,0,0.2)), 
		(2.7, (0.9,0.2,0,0.4)), 
		(3.2, (0.6,0.1,0.05,0.2)), 
		(4.0, (0.8,0.8,0.8,0.1)),
		(6.0, (0.8,0.8,0.8,0)), ]
	),
)

group = ParticleGroup(controllers=[flame], 
	renderer=PointRenderer(64, SpriteTexturizer(create_point_texture(64, 5))))

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0/30.0))
pyglet.clock.set_fps_limit(None)

@win.event
def on_draw():
	win.clear()
	glLoadIdentity()
	default_system.draw()

if __name__ == '__main__':
	default_system.run_ahead(2, 30)
	pyglet.app.run()