2021-06-26 14:15:33 +08:00
|
|
|
import time
|
|
|
|
|
|
|
|
import pyglet
|
|
|
|
|
|
|
|
window = pyglet.window.Window(resizable=True)
|
|
|
|
|
2021-08-24 22:31:52 +08:00
|
|
|
ball_image = pyglet.image.load('../textures/Atmospheres.png') # 可自定义材质
|
2021-06-26 14:15:33 +08:00
|
|
|
batch = pyglet.graphics.Batch()
|
|
|
|
|
|
|
|
ball_sprites = []
|
|
|
|
start_t = time.time()
|
2021-08-24 22:31:52 +08:00
|
|
|
for i in range(100000): # 可自定义数量
|
2021-07-08 20:42:22 +08:00
|
|
|
x, y = i * 30, 50
|
2021-06-26 14:15:33 +08:00
|
|
|
ball_sprites.append(pyglet.sprite.Sprite(ball_image, x, y, batch=batch))
|
2021-08-24 22:31:52 +08:00
|
|
|
ball_sprites[i - 1].visible = True
|
2021-06-26 14:15:33 +08:00
|
|
|
end_t = time.time()
|
2021-07-08 20:42:22 +08:00
|
|
|
print(start_t, end_t, end_t - start_t)
|
|
|
|
|
|
|
|
a = 1
|
|
|
|
|
2021-06-26 14:15:33 +08:00
|
|
|
|
|
|
|
@window.event
|
|
|
|
def on_draw():
|
|
|
|
start_t = time.time()
|
2021-08-24 22:31:52 +08:00
|
|
|
batch.draw()
|
2021-06-26 14:15:33 +08:00
|
|
|
end_t = time.time()
|
2021-07-08 20:42:22 +08:00
|
|
|
print(start_t, end_t - start_t)
|
2021-06-26 14:15:33 +08:00
|
|
|
print(end_t, pyglet.clock.get_fps(), 'fps')
|
|
|
|
|
2021-07-08 20:42:22 +08:00
|
|
|
|
2021-06-26 14:15:33 +08:00
|
|
|
pyglet.app.run()
|