pyglet

why does my window doesn't work for on_draw?

♀尐吖头ヾ 提交于 2020-07-22 06:31:38
问题 I was watching a video about pyglet and I tried to create a triangle: import pyglet from pyglet.gl import * class mywindow(pyglet.window.Window): def __init__(self, *args,**kwargs): super().__init__(*args,**kwargs) self.set_minimum_size(300,300) window = mywindow(300,300,"deneme", True) def on_draw(): glBegin(GL_TRIANGLE) glColor3b(255,0,0) glVertex2f(-1,0) glColor3b(0,255,0) glVertex2f(1,0) glColor3b(0,0,255) glVertex2f(0,1) window.on_draw() pyglet.app.run() when I run this code; I get this

How to make an image move through a pyglet window?

大兔子大兔子 提交于 2020-06-17 13:25:07
问题 I am trying to make an animation using pyglet. So first I tried a simple animation, moving the image in a strait line. Idealy I would like it to bounce around from left to right. Here is my code: import pyglet def center_image(image): """Sets an image's anchor point to its center""" image.anchor_x = image.width // 2 image.anchor_y = image.height // 2 # Make window. window = pyglet.window.Window(width=640, height=480) # Load image. pyglet.resource.path = ['images'] pyglet.resource.reindex()