本文介绍了使用Python,ruby或LUA进行游戏开发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Action Script 3和C ++的某些游戏引擎中有游戏开发经验.但是,我想提高生产率,所以我想用Python,ruby或LUA开发一个新项目.这是个好主意吗?如果是,您会建议哪一个?什么是杀手级游戏开发工具集或引擎?

I have experience in game development in some game engines in Action Script 3 and C++.However, I would like to improve the productivity and so I want to develop a new project in Python, ruby or LUA.Would it be a good idea? If yes, which one would you suggest? and what is the killer game development tool set or engine?

推荐答案

如果您有什么好处,请使用 Pyglet .
这是针对OpenGL的跨平台Python版本独立挂钩,具有出色的性能.这有点棘手,但它的工作要比Python世界中其他任何地方都要好.

If you're any good, go with Pyglet.
It's a cross-platform Python version independent hook against OpenGL with outstanding performance. It's a bit tricky but it does the job better than anything else out there in the Python world.

如果您是初学者,我会选择 Pygame .
这对系统来说有点累,但是对于一台现代计算机来说这不是问题.此外,它还具有用于游戏开发的预包装API(因此得名):)

If you're a beginner, i'd go with Pygame.
It's a bit taxing on the system but with a modern computer that isn't a issue.. also, it got pre-packaged API's for game development (hence the name) :)

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

A "official" list of Python gaming/graphic engines:http://wiki.python.org/moin/PythonGames

一些好的:

  • Panda3D
  • 小矮人
  • PyGame
  • Blender3D
#!/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()



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

You'll have to download the 1.2alpha1 otherwise it will complain about you not having Python3.X installed :)

这篇关于使用Python,ruby或LUA进行游戏开发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:00