【问题标题】:Game Development in Python, ruby or LUA? [closed]使用 Python、Ruby 或 LUA 进行游戏开发? [关闭]
【发布时间】:2013-03-31 13:25:54
【问题描述】:

我有使用 Action Script 3 和 C++ 开发某些游戏引擎的经验。 但是,我想提高生产力,所以我想用 Python、ruby 或 LUA 开发一个新项目。 这会是个好主意吗?如果是的话,你会推荐哪一个?什么是杀手级游戏开发工具集或引擎?

【问题讨论】:

  • Unity 也支持 Lua。

标签: python ruby lua game-engine


【解决方案1】:

如果你有任何好处,请使用Pyglet
它是一个针对 OpenGL 的跨平台 Python 版本独立钩子,具有出色的性能。这有点棘手,但它比 Python 世界中的其他任何东西都做得更好。

如果您是初学者,我会选择Pygame
这对系统有点负担,但对于现代计算机来说这不是问题。而且,它有用于游戏开发的预打包 API(因此得名):)

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

一些不错的:

  • 熊猫3D
  • 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='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 与 Python 3.X 的注意事项:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2019-04-21
    • 1970-01-01
    • 2012-01-10
    相关资源
    最近更新 更多