Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pyglet - Batch Group
import pyglet
#index all resources
pyglet.resource.path = ['resources']
pyglet.resource.reindex()
#create window object
screen = pyglet.window.Window(800, 600)
#create batch group to put all objects in
main_batch = pyglet.graphics.Batch()
#create player object
player_image = pyglet.resource.image("player.png")
player_sprite = pyglet.sprite.Sprite(img=player_image,x=400,y=300, batch=main_batch)
#create text label
score_label = pyglet.text.Label(text="Hello World", x=100, y=500, batch=main_batch)
@screen.event
def on_draw():
screen.clear()
#draw batch group (player and text)
main_batch.draw()
if __name__ == "__main__":
pyglet.app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment