futnuh
25-03-2007 06:16:46
I'm in the middle of porting an existing pyogre application over to python-ogre. I'd greatly appreciate any advice regarding python-ogre best practices for reimplementing the following code.
It's been awhile but I take it that EventProcessor is a pyogre construct? Also, looking through the python-ogre ogre demos there is reliance on a SampleFramework. Is it suggested that we use this for real projects, or as with Ogre, should we be "rolling our own"?
#import pyogre.ogre as ogre
import Ogre as ogre
#class FrameListener(ogre.CombinedListener, object):
class FrameListener(ogre.FrameListener, object):
def __init__(self):
#ogre.CombinedListener.__init__(self)
ogre.FrameListener.__init__(self)
self._keeprendering = True
self._framenumber = 0
def setWindow(self, window):
self._window = window
self._eventprocessor = ogre.EventProcessor()
self._eventprocessor.initialise(self._window)
self._eventprocessor.startProcessingEvents()
self._eventprocessor.addKeyListener(self)
self._eventprocessor.addMouseListener(self)
self._eventprocessor.addMouseMotionListener(self)
def getWindow(self):
return self._window
window = property(getWindow, setWindow)
def frameStarted(self, frameEvent):
"""Simplest of frame callbacks allows for quitting"""
self._framenumber += 1
return self._keeprendering
def keyPressed(self, event):
if event.key == ogre.KC_ESCAPE:
self._keeprendering = False
def frameEnded(self, frameEvent):
return True
def mousePressed(self, event):
if event.buttonID & ogre.MouseEvent.BUTTON0_MASK:
doSomething()
It's been awhile but I take it that EventProcessor is a pyogre construct? Also, looking through the python-ogre ogre demos there is reliance on a SampleFramework. Is it suggested that we use this for real projects, or as with Ogre, should we be "rolling our own"?