您应该完全旋转电路板。
截取屏幕截图并旋转几乎与旋转棋盘对象一样费力。批处理对象并旋转它们将是一个解决方案。
编辑:我刚刚意识到 Pygame 是少数可能会错过批处理渲染的库之一。 Pygame 不错,适合入门学习曲线,但你最好使用其他库(这只是一个友好的建议)
友情建议
如果我真的想做一些很酷的事情(包括你规模的游戏开发),我会选择 Pyglet。
它是跨平台的,不依赖于 Python 版本,就像所有其他版本一样,您可以直接连接到 OpenGL 库,使其速度非常快。而且它实际上很容易使用。
这里是拖放示例:
#!/usr/bin/python
import pyglet
from time import time, sleep
class Window(pyglet.window.Window):
def __init__(self, refreshrate):
super(Window, self).__init__(vsync = False)
self.frames = 0
self.framerate = pyglet.text.Label(text='Unknown', font_name='Verdana', font_size=8, x=10, y=10, color=(255,255,255,255))
self.last = time()
self.alive = 1
self.refreshrate = refreshrate
self.click = None
self.drag = False
def on_draw(self):
self.render()
def on_mouse_press(self, x, y, button, modifiers):
self.click = x,y
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
if self.click:
self.drag = True
print 'Drag offset:',(dx,dy)
def on_mouse_release(self, x, y, button, modifiers):
if not self.drag and self.click:
print 'You clicked here', self.click, 'Relese point:',(x,y)
else:
print 'You draged from', self.click, 'to:',(x,y)
self.click = None
self.drag = False
def render(self):
self.clear()
if time() - self.last >= 1:
self.framerate.text = str(self.frames)
self.frames = 0
self.last = time()
else:
self.frames += 1
self.framerate.draw()
self.flip()
def on_close(self):
self.alive = 0
def run(self):
while self.alive:
self.render()
# ----> Note: <----
# Without self.dispatc_events() the screen will freeze
# due to the fact that i don't call pyglet.app.run(),
# because i like to have the control when and what locks
# the application, since pyglet.app.run() is a locking call.
event = self.dispatch_events()
sleep(1.0/self.refreshrate)
win = Window(23) # set the fps
win.run()
Pyglet 还使您能够进行批量渲染(这意味着您可以将指令以大块的形式发送到 GPU,而不是逐项发送,这样可以轻松快速、轻松地完成复杂的任务。您也可以这样做 @987654322 @你就完成了)