Hey thanks for the replies! I will certainly try both alternatives to see which has the best results. I wouldn't have thought to just add the data manually, I figured there might of been a built in function but that should work since sprites also list their vertices.
Now that I have my tilemap, is this the same way people handle ordering their movable sprites? In an isometric or RTS type game, each object needs to overlap the object above it depending on the position. For instance, all moveable objects must be able to change their order when their position changes; so, for example, they can appear behind objects, like trees, then they appear in front of them as they move down. Or when you have many trees overlapping eachother to create a forest effect. How is this accomplished in Pyglet? I certainly can't use hundreds of ordered groups. (Seems it has problems with even just a handful of ordered groups, even.) Is it the same concept of deleting them from batch, put them in a list, sorting that list on the Y criteria, then adding back to a batch one by one? Thanks. On Thursday, April 28, 2016 at 4:09:53 PM UTC-5, [email protected] wrote: > > You can keep a list of the sprites for adding and removing them from > batches: > > import pyglet > from pyglet.gl import * > > window = pyglet.window.Window(640,480) > > rendered_sprites = [] > > batch = pyglet.graphics.Batch() > > texture = pyglet.image.load('test.png').get_texture() > > @window.event > def on_draw(): > window.clear() > batch.draw() > > @window.event > def on_key_press(symbol,modifiers): > if symbol == pyglet.window.key.RETURN: > rendered_sprites.append(batch.add(4, GL_QUADS, None, > ('v2f/static', (0.0,0.0, 32.0, > 0.0, 32.0,32.0, 0.0,32.0)), > ('t3f/static', texture. > tex_coords))) > > if symbol == pyglet.window.key.SPACE: > rendered_sprites.pop(0).delete() > > pyglet.app.run() > > You could also create two separate batches, one for active rendering and > one for idle storage, then migrate selected sprites from one batch to > another, though it may not be as efficient as other methods: > > import pyglet > from pyglet.gl import * > > window = pyglet.window.Window(640,480) > > rendered_sprites = [] > > batch = pyglet.graphics.Batch() > > batch_idle = pyglet.graphics.Batch() > > texture = pyglet.image.load('test.png').get_texture() > > rendered_sprites.append(batch.add(4, GL_QUADS, None, > ('v2f/static', (0.0,0.0, 32.0,0.0, 32.0, > 32.0, 0.0,32.0)), > ('t3f/static', texture.tex_coords))) > > @window.event > def on_draw(): > window.clear() > batch.draw() > > @window.event > def on_key_press(symbol,modifiers): > if symbol == pyglet.window.key.RETURN: > batch.migrate(rendered_sprites[0],pyglet.gl.GL_QUADS, None, > batch_idle) > > if symbol == pyglet.window.key.SPACE: > batch_idle.migrate(rendered_sprites[0],pyglet.gl.GL_QUADS, > None,batch) > > pyglet.app.run() > > > > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/pyglet-users. For more options, visit https://groups.google.com/d/optout.
