Action Script 3 および C++ を使用したいくつかのゲーム エンジンでのゲーム開発の経験があります。しかし、生産性を向上させたいので、Python、ruby、または LUA で新しいプロジェクトを開発したいと考えています。それは良い考えでしょうか?はいの場合、どちらをお勧めしますか? キラー ゲーム開発ツール セットまたはエンジンは何ですか?
2952 次
1 に答える
1
あなたが得意なら、Pygletを使ってください。
これは、OpenGL に対するクロスプラットフォームの Python バージョンに依存しないフックであり、優れたパフォーマンスを発揮します。少しトリッキーですが、Python の世界の他のどのツールよりもうまく機能します。
あなたが初心者なら、私はPygameを使います。
システムには少し負担がかかりますが、最新のコンピューターでは問題ありません..また、ゲーム開発用の事前にパッケージ化された API を取得しています (名前の由来) :)
Python ゲーム/グラフィック エンジンの「公式」リスト: http://wiki.python.org/moin/PythonGames
いくつかの良いもの:
- パンダ3D
- ピグレット
- パイゲーム
- Blender3D
Pyglet コードの例:
#!/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()
Python 3.X を使用する Pyglet に関する注意:
1.2alpha1をダウンロードする必要があります。そうしないと、Python3.X がインストールされていないと文句を言うでしょう :)
于 2013-04-09T08:04:03.877 に答える