def _reload(self): # If no clips available return if self.clips <= 0: return # If we are already reloading return if hasattr(self, 'reloading'): return # Mark that we are reloading, disable firing # and run _reload_p in parallel self.reloading = 1 self.mCanFire -= 1 mthread.parallelize(self._reload_p)
def startup(self): sylphis.CClient.startup_c(self) self.actors = actor.CActors(self) # Create the hud self.hud = hudbase.CHUDBase() # Register the console to the global # Sylphis console import ui e = CEngine #e.renderer.setMotionBlurAmount(0.3) e.con.addConsole(ui.con) self.dFont = CEngine.getDefaultFont() # Load map fire requested by command line arguments map = cmdline.getParamValue('map') if map != None: self.loadMap("maps/" + map) else: pyui.activate() self.inputListener = CClientInput() CEngine.getInput().addListener(self.inputListener) self.faderShader = CEngine.mMaterials.registerMaterial('fader') self.glareShader = CEngine.mMaterials.registerMaterial('glare') self.oldFilmGlare = CEngine.mMaterials.registerMaterial('oldfilmglare') self.oldFilm = CEngine.mMaterials.registerMaterial('oldfilm') self.motionBlur = CEngine.mMaterials.registerMaterial('motionblur') self.bufferA = CEngine.mMaterials.registerMaterial('bufferA') self.bufferAb = CEngine.mMaterials.registerMaterial('bufferAb') self.timeLeft = 300.0 mthread.parallelize(self.updateHudTime)
def remove(self, a): mthread.parallelize(self.remove_p, a)
## ## The function that does the measurement ## def bench(): mthread.sleep(0.1) # Sleep a little time to let things settle timer = sylphis.CTimer() # Generate a timer to count time startFrame = CEngine.getFrameCount( ) # Log the number of frames rendered by the engine at the start of the benchmark mthread.sleep(50.0) # Sleep for 50.0 seconds of game world time time = timer.getTime( ) # Read the real world time it took to render all the frames frames = float( CEngine.getFrameCount() - startFrame) # Calculate the number of frames the engine rendered print "Average FPS : %4.2f" % (frames / time) shutdown() # Shutdown the engine CClient.loadMap('maps/last.cmap') # Load the benchmark map pyui.deactivate() # Deactivate the GUI CEngine.setFPS( 30.0) # Set the engine to generate a constant frames per game world second mthread.parallelize(bench) # Run bench() in parallel
def _dryFire(self): # Disable firing self.mCanFire -= 1 # Run the dryfire method in parallel mthread.parallelize(self._dryFire_p)
import sylphis import pyui import mthread ## ## The function that does the measurement ## def bench(): mthread.sleep(0.1) # Sleep a little time to let things settle timer = sylphis.CTimer() # Generate a timer to count time startFrame = ( CEngine.getFrameCount() ) # Log the number of frames rendered by the engine at the start of the benchmark mthread.sleep(50.0) # Sleep for 50.0 seconds of game world time time = timer.getTime() # Read the real world time it took to render all the frames frames = float(CEngine.getFrameCount() - startFrame) # Calculate the number of frames the engine rendered print "Average FPS : %4.2f" % (frames / time) shutdown() # Shutdown the engine CClient.loadMap("maps/last.cmap") # Load the benchmark map pyui.deactivate() # Deactivate the GUI CEngine.setFPS(30.0) # Set the engine to generate a constant frames per game world second mthread.parallelize(bench) # Run bench() in parallel
lightDir = sylphis.CVector3() def setLightDir_(a,b = 10,c = 1): global lightDir if b == 10: b = 1.0 - a lightDir.x = a; lightDir.y = b; lightDir.z = c; lightDir = lightDir.normalized() def setLightDir(a,b = 10,c = 1): import entry entry.client.actors.getActorByName('l1').node.setOrientation(sylphis.CQuaternion(1,0,0,a)*sylphis.CQuaternion(0,1,0,0.2)) def getLightDir(): return lightDir.x, lightDir.y, lightDir.z import mthread def daynight(): t = 0.0 mthread.sleep(15.0) while t < 10.0: setLightDir((t * 0.08) % 2.0) t += mthread.sleep(0.0001) mthread.parallelize(daynight)