def run(self): """I am called to begin the running of the game. """ running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame endFrame = pyui.readTimer() if self.world.update(interval) == 0: running = 0 else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print "FPS: %2d mobiles: %d statics: %d " % ( FPS, len(self.world.mobiles), len(self.world.immobiles))
def run(self): """Run the game through a loop""" running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame endFrame = pyui.readTimer() else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print 'FPS: %2d' % (FPS)
def run(self): """I am called to begin running the game. """ running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame endFrame = pyui.readTimer() if self.client.update(interval) == 0: running = 0 else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print "FPS: %2d" % (FPS ) time.sleep(0.03)
def run(self): """I am called to begin the running of the game. """ running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame endFrame = pyui.readTimer() if self.world.update(interval) == 0: running = 0 else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print "FPS: %2d mobiles: %d statics: %d " % (FPS, len(self.world.mobiles), len(self.world.immobiles) )
def run(self): running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame self.world.update(interval) endFrame = pyui.readTimer() else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print "FPS: %2d" % (FPS)
def run(self): running = 1 frames = 0 counter = 0 lastFrame = pyui.readTimer() endFrame = pyui.readTimer() while running: pyui.draw() if pyui.update(): interval = pyui.readTimer() - endFrame self.world.update(interval) endFrame = pyui.readTimer() else: running = 0 # track frames per second frames += 1 counter += 1 # calculate FPS if endFrame - lastFrame > 1.0: FPS = counter counter = 0 lastFrame = endFrame print "FPS: %2d" % (FPS )
def setInitialState(self, stateName, layerName): """Set the initial state of a layer. """ layer = StateManager.layers.get(layerName, None) if layer: state = layer.get(stateName) if state: interval = state.enter(self.actor) self.currentStates[layerName] = state self.updateTimes[layerName] = pyui.readTimer() + interval return 1 raise StateException("No state %s or layer %s" % (stateName, layerName) )
def setInitialState(self, stateName, layerName): """Set the initial state of a layer. """ layer = StateManager.layers.get(layerName, None) if layer: state = layer.get(stateName) if state: interval = state.enter(self.actor) self.currentStates[layerName] = state self.updateTimes[layerName] = pyui.readTimer() + interval return 1 raise StateException("No state %s or layer %s" % (stateName, layerName))
def gotoState(self, newStateName, layerName): """Set a layer to a state. """ layer = StateManager.layers.get(layerName) if not layer: raise StateException("No layer %s" % layerName) currentState = self.currentStates.get(layerName) if not currentState: raise StateException("No curreState for layer %s" % layerName) newState = layer.get(newStateName, None) if not newState: raise StateException("New state %s doesnt exist" % newStateName) currentState.leave(self.actor) self.currentStates[layerName] = newState interval = newState.enter(self.actor) self.updateTimes[layerName] = pyui.readTimer() + interval return 1
def updateStates(self): now = pyui.readTimer() for layerName, updateTime in self.updateTimes.items(): if now >= updateTime: interval = self.currentStates[layerName].update(self.actor) self.updateTimes[layerName] = now + interval