使用Python、Ruby或LUA进行游戏开发?

我有使用 Action Script 3 和 C++ 开发游戏的经验。然而,我想提高生产力,所以我想使用 Python、Ruby 或 LUA 开发新项目。这个想法好吗?如果好的话,你会建议我使用哪个?还有,游戏开发的杀手级工具集或引擎是什么?

点赞
用户929999
用户929999

如果你很擅长,使用Pyglet

它是一个跨平台的Python版本独立的OpenGL钩子,拥有优秀的性能。虽然有点棘手,但在Python世界里做得比其他任何东西都要好。

如果你是初学者,我会选择Pygame

它对系统而言有些费力,但对于现代计算机来说不是问题。此外,它有预先打包的API适用于游戏开发(因此得名):)

一个“官方”的Python游戏/图形引擎列表: http://wiki.python.org/moin/PythonGames

一些好的引擎:

  • Panda3D
  • Pyglet
  • PyGame
  • 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='未知', 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 '拖动偏移:',(dx,dy)

    def on_mouse_release(self, x, y, button, modifiers):
        if not self.drag and self.click:
            print '您在此处单击', self.click, '释放点:',(x,y)
        else:
            print '您从', self.click, '拖动到:',(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()
            # ----> 注意:<----
            #  如果不使用self.dispatc_events(),屏幕将会冻结,
            #  因为我没有调用pyglet.app.run(),
            #  因为我喜欢掌控何时以及什么可能会锁定应用程序,
            #  因为pyglet.app.run()是一个锁定调用。
            event = self.dispatch_events()
            sleep(1.0/self.refreshrate)

win = Window(23)#设置帧率
win.run()

#关于Python 3.X的Pyglet的说明:

你需要下载1.2alpha1,否则它会抱怨你没有安装Python3.X :)

2013-04-09 08:04:03