| 1 |
import pyglet |
| 2 |
|
| 3 |
window = pyglet.window.Window(resizable=True) |
| 4 |
|
| 5 |
|
| 6 |
pyglet.resource.path = ['../resources'] |
| 7 |
pyglet.resource.reindex() |
| 8 |
|
| 9 |
|
| 10 |
image = pyglet.resource.image("pyglet.png") |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
image.anchor_x = image.width // 2 |
| 15 |
image.anchor_y = image.height // 2 |
| 16 |
|
| 17 |
|
| 18 |
sprite = pyglet.sprite.Sprite(image, x=window.width // 2, y=window.height // 2) |
| 19 |
|
| 20 |
@window.event |
| 21 |
def on_resize(width, height): |
| 22 |
|
| 23 |
sprite.update(x=width // 2, y=height // 2) |
| 24 |
|
| 25 |
@window.event |
| 26 |
def on_draw(): |
| 27 |
window.clear() |
| 28 |
sprite.draw() |
| 29 |
|
| 30 |
pyglet.app.run() |