当前位置: 首页>>代码示例>>Python>>正文


Python GameEngine.quit方法代码示例

本文整理汇总了Python中GameEngine.GameEngine.quit方法的典型用法代码示例。如果您正苦于以下问题:Python GameEngine.quit方法的具体用法?Python GameEngine.quit怎么用?Python GameEngine.quit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GameEngine.GameEngine的用法示例。


在下文中一共展示了GameEngine.quit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ViewTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class ViewTest(unittest.TestCase):
    def testTransition(self):
        l1 = TestLayer()
        l2 = TestLayer()
        l3 = TestLayer()
        v = self.e.view

        v.pushLayer(l1)
        v.pushLayer(l2)
        v.pushLayer(l3)

        while l3.visibility < 1.0:
            self.e.run()

        v.popLayer(l3)
        v.popLayer(l2)
        v.popLayer(l1)

        while l1 in v.layers or l2 in v.layers or l3 in v.layers:
            self.e.run()

        assert not v.layers

    def setUp(self):
        self.e = GameEngine()

    def tearDown(self):
        self.e.quit()
开发者ID:Hawkheart,项目名称:fof-reborn,代码行数:30,代码来源:ViewTest.py

示例2: ViewTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class ViewTest(unittest.TestCase):
    def testTransition(self):
        l1 = TestLayer()
        l2 = TestLayer()
        l3 = TestLayer()
        v = self.e.view

        v.pushLayer(l1)
        v.pushLayer(l2)
        v.pushLayer(l3)

        while l3.visibility < 1.0:
            self.e.run()

        v.popLayer(l3)
        v.popLayer(l2)
        v.popLayer(l1)

        while l1 in v.layers or l2 in v.layers or l3 in v.layers:
            self.e.run()

        assert not v.layers

    def setUp(self):
        config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        self.e = GameEngine(config)

    def tearDown(self):
        self.e.quit()
开发者ID:Archangelgray,项目名称:fofix,代码行数:31,代码来源:ViewTest.py

示例3: DialogTestInteractive

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class DialogTestInteractive(unittest.TestCase):
  def testGetTest(self):
    text = getText(self.e, "Please enter your name:", "Wario")
     
  def setUp(self):
    self.e = GameEngine()
    
  def tearDown(self):
    self.e.quit()
开发者ID:fretsonfire,项目名称:fof-python,代码行数:11,代码来源:DialogTest.py

示例4: DialogTestInteractive

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class DialogTestInteractive(unittest.TestCase):
  def testGetTest(self):
    text = getText(self.e, "Please enter your name:", "Wario")
     
  def setUp(self):
    config = Config.load(Version.appName() + ".ini", setAsDefault = True)
    self.e = GameEngine(config)
    
  def tearDown(self):
    self.e.quit()
开发者ID:Gamer125,项目名称:fofix,代码行数:12,代码来源:DialogTest.py

示例5: ResourceTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class ResourceTest(unittest.TestCase):
    def testAsynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.r.load(self, "result", lambda: loader())

        while not self.result:
            self.e.run()

        assert self.result == 0xdada

    def testSynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        assert self.r.load(self, "result2", loader, synch = True) == 0xdada
        assert self.result2 == 0xdada

    def testAsynchLoadSeries(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        for i in range(10):
            self.r.load(self, "result%d" % i, loader)

        while not self.result9:
            self.e.run()

        assert self.result9 == 0xdada

    def testCallback(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.quux = None
        def loaded(r):
            self.quux = r

        self.r.load(self, "fuuba", loader, onLoad = loaded).join()

        while not self.fuuba:
            self.e.run()

        assert self.fuuba == self.quux

    def setUp(self):
        Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        # Resource expects game_priority to be an integer,
        # Config won't know unless we define it as such.
        Config.define("performance", "game_priority", int, 2)
        self.e = GameEngine()

    def tearDown(self):
        self.e.quit()
开发者ID:Richardgriff,项目名称:fofix,代码行数:57,代码来源:ResourceTest.py

示例6: MenuTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class MenuTest(unittest.TestCase):
    def testMenuNavigation(self):
        m = Menu(self.e, rootMenu)
        self.e.view.pushLayer(m)

    def setUp(self):
        config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        self.e = GameEngine(config)

    def tearDown(self):
        self.e.quit()
开发者ID:Richardgriff,项目名称:fofix,代码行数:13,代码来源:MenuTest.py

示例7: MenuTestInteractive

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class MenuTestInteractive(unittest.TestCase):
  def testMenuNavigation(self):
    m = Menu(self.e, rootMenu)
    self.e.view.pushLayer(m)

    while self.e.view.layers:
      self.e.run()

  def setUp(self):
    config = Config.load(Version.appName() + ".ini", setAsDefault = True)
    self.e = GameEngine(config)
    
  def tearDown(self):
    self.e.quit()
开发者ID:Gamer125,项目名称:fofix,代码行数:16,代码来源:MenuTest.py

示例8: MenuTestInteractive

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class MenuTestInteractive(unittest.TestCase):
    def testMenuNavigation(self):
        m = Menu(self.e, rootMenu)
        self.e.view.pushLayer(m)

        while self.e.view.layers:
            rootMenu[0][0] = "%.1f FPS" % self.e.fpsEstimate
            self.e.run()

    def setUp(self):
        self.e = GameEngine()

    def tearDown(self):
        self.e.quit()
开发者ID:fofix,项目名称:fof-reborn,代码行数:16,代码来源:MenuTest.py

示例9: MenuTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class MenuTest(unittest.TestCase):
    def testMenuNavigation(self):
        m = Menu(self.e, rootMenu)
        self.e.view.pushLayer(m)

        while self.e.view.layers and 0:
            rootMenu[0][0] = "%.1f FPS" % self.e.fpsEstimate
            self.e.run()
        # FIXME: keyboard event injection for testing

    def setUp(self):
        self.e = GameEngine()

    def tearDown(self):
        self.e.quit()
开发者ID:fofix,项目名称:fof-reborn,代码行数:17,代码来源:MenuTest.py

示例10: testNetworking

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
    def testNetworking(self):
        config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        e1 = GameEngine(config)

        e1.startServer()
        session1 = e1.connect("localhost")
        session2 = e1.connect("localhost")

        while not session1.isConnected() or not session2.isConnected():
            e1.run()

        session1.world.createPlayer("mario")
        session2.world.createPlayer("luigi")

        for i in range(10):
            e1.run()

        assert len(e1.server.world.players) == 2
        assert len(session1.world.players) == 2
        assert len(session2.world.players) == 2

        session3 = e1.connect("localhost")

        for i in range(10):
            e1.run()

        assert len(session3.world.players) == 2

        session1.disconnect()

        for i in range(10):
            e1.run()

        assert len(e1.server.world.players) == 1
        assert len(session2.world.players) == 1

        e1.quit()
开发者ID:Richardgriff,项目名称:fofix,代码行数:39,代码来源:GameEngineTest.py

示例11: testNetworking

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
  def testNetworking(self):
    e1 = GameEngine()
    
    e1.startServer()
    session1 = e1.connect("localhost")
    session2 = e1.connect("localhost")

    while not session1.isConnected() or not session2.isConnected():
      e1.run()

    session1.world.createPlayer("mario")
    session2.world.createPlayer("luigi")
    
    for i in range(10):
      e1.run()

    assert len(e1.server.world.players) == 2
    assert len(session1.world.players) == 2
    assert len(session2.world.players) == 2
    
    session3 = e1.connect("localhost")
    
    for i in range(10):
      e1.run()

    assert len(session3.world.players) == 2

    session1.disconnect()
    
    for i in range(10):
      e1.run()

    assert len(e1.server.world.players) == 1
    assert len(session2.world.players) == 1

    e1.quit()
开发者ID:fretsonfire,项目名称:fof-python,代码行数:38,代码来源:GameEngineTest.py

示例12: int

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
        if playing != None:
            Config.set("game", "selected_library", "songs")
            Config.set("game", "selected_song", playing)
            engine.cmdPlay = 1
            engine.cmdDiff = int(difficulty)
            engine.cmdPart = int(part)
            # evilynux - Multiplayer and mode selection support
            Config.set("game", "players", nbrplayers)
            Config.set("player0", "mode_1p", mode)
            Config.set("player1", "mode_2p", mode)

        if debug == True:
            engine.setDebugModeEnabled(not engine.isDebugModeEnabled())
            engine.debugLayer.debugOut(engine)
            engine.quit()
            break

        encoding = Config.get("game", "encoding")
        if encoding != None:
            reload(sys)
            sys.setdefaultencoding(encoding)
        engine.setStartupLayer(MainMenu(engine))

        try:
            import psyco

            psyco.profile()
        except:
            Log.warn("Unable to enable psyco.")
开发者ID:Gamer125,项目名称:fofix,代码行数:31,代码来源:FretsOnFire.py

示例13: main

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
def main():
  """Main thread"""

  try:
    opts, args = getopt.getopt(sys.argv[1:], "vdc:p:D:P:m:N:", ["verbose", "debug", "config=", "play=", "diff=", "part=", "mode=", "nbrplayers="])
  except getopt.GetoptError:
    print usage
    sys.exit(1)
    
  playing = None
  configFile = None
  debug = False
  difficulty = 0
  part = 0
  mode = 0
  nbrplayers = 1
  for opt, arg in opts:
    if opt in ["--verbose", "-v"]:
      Log.quiet = False
    if opt in ["--debug", "-d"]:
      debug = True
    if opt in ["--config", "-c"]:
      configFile = arg
    if opt in ["--play", "-p"]:
      playing = arg
    if opt in ["--diff", "-D"]:
      difficulty = arg      
    if opt in ["--part", "-P"]:
      part = arg
    #evilynux - Multiplayer and mode selection support
    if opt in ["--mode", "-m"]:
      mode = int(arg)
    if opt in ["--nbrplayers", "-N"]:
      nbrplayers = int(arg)
      
  while True:
    if configFile != None:
      if configFile.lower() == "reset":
        fileName = os.path.join(Resource.getWritableResourcePath(), Version.appName() + ".ini")
        os.remove(fileName)
        config = Config.load(Version.appName() + ".ini", setAsDefault = True)
      else:
        config = Config.load(configFile, setAsDefault = True)
    else:
      config = Config.load(Version.appName() + ".ini", setAsDefault = True)
    engine = GameEngine(config)
    engine.cmdPlay = 0
    
    if playing != None:
      Config.set("game", "selected_library", "songs")
      Config.set("game", "selected_song", playing)
      engine.cmdPlay = 1
      engine.cmdDiff = int(difficulty)
      engine.cmdPart = int(part)
      #evilynux - Multiplayer and mode selection support
      Config.set("game", "players", nbrplayers)
      Config.set("player0","mode_1p", mode)
      Config.set("player1","mode_2p", mode)

    if debug == True:
      engine.setDebugModeEnabled(not engine.isDebugModeEnabled())
      engine.debugLayer.debugOut(engine)
      engine.quit()
      break
      
    encoding = Config.get("game", "encoding")
    if encoding != None:
      reload(sys)
      sys.setdefaultencoding(encoding)
    engine.setStartupLayer(MainMenu(engine))

    try:
      import psyco
      psyco.profile()
    except:
      Log.warn("Unable to enable psyco.")

    try:
      while engine.run():
        pass
    except KeyboardInterrupt:
        pass
    if engine.restartRequested:
      Log.notice("Restarting.")
      engine.audio.close()
      try:
        # Determine whether were running from an exe or not
        if hasattr(sys, "frozen"):
          if os.name == "nt":
            os.execl("FretsOnFire.exe", "FretsOnFire.exe", *sys.argv[1:])
          elif sys.frozen == "macosx_app":
            import string
            import subprocess
            appname = string.join(string.split(sys.executable, '/')[:-1], '/')
            appname = appname+"/Frets on Fire"
            subprocess.Popen(`appname`, shell=True)
          else:
            os.execl("./FretsOnFire", "./FretsOnFire", *sys.argv[1:])
        else:
          if os.name == "nt":
#.........这里部分代码省略.........
开发者ID:Gamer125,项目名称:fofix,代码行数:103,代码来源:FretsOnFire.py

示例14: main

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]

#.........这里部分代码省略.........
  if theme is not None:
    Config.set("coffee", "themename", theme)

  engine = GameEngine(config)
  engine.cmdPlay = 0

  # Check for a valid invocation of one-shot mode.
  if playing is not None:
    Log.debug('Validating song directory for one-shot mode.')
    library = Config.get("game","base_library")
    basefolder = os.path.join(Version.dataPath(),library,"songs",playing)
    if not (os.path.exists(os.path.join(basefolder, "song.ini")) and (os.path.exists(os.path.join(basefolder, "notes.mid")) or os.path.exists(os.path.join(basefolder, "notes-unedited.mid"))) and (os.path.exists(os.path.join(basefolder, "song.ogg")) or os.path.exists(os.path.join(basefolder, "guitar.ogg")))):
      Log.warn("Song directory provided ('%s') is not a valid song directory. Starting up FoFiX in standard mode." % playing)
      engine.startupMessages.append(_("Song directory provided ('%s') is not a valid song directory. Starting up FoFiX in standard mode.") % playing)
      playing = None

  # Set up one-shot mode if the invocation is valid for it.
  if playing is not None:
    Log.debug('Entering one-shot mode.')
    Config.set("game", "selected_library", "songs")
    Config.set("game", "selected_song", playing)
    engine.cmdPlay = 1
    if difficulty is not None:
      engine.cmdDiff = int(difficulty)
    if part is not None:
      engine.cmdPart = int(part)
    #evilynux - Multiplayer and mode selection support
    Config.set("game", "players", nbrplayers)
    if nbrplayers == 1:
      Config.set("game", "game_mode", mode)
    else:
      Config.set("game", "game_mode", 0)
      Config.set("game", "multiplayer_mode", mode)

  if debug:
    engine.setDebugModeEnabled(not engine.isDebugModeEnabled())
    engine.debugLayer.debugOut(engine)
    engine.quit()
    return

  encoding = Config.get("game", "encoding")
  if encoding is not None:
    #stump: XXX: Everything I have seen indicates that this is a
    # horrible, horrible hack.  Is there another way?  Do we even need this?
    reload(sys)
    sys.setdefaultencoding(encoding)

  engine.setStartupLayer(MainMenu(engine))

  #stump: make psyco optional
  if Config.get("performance", "use_psyco"):
    try:
      import psyco
      psyco.profile()
    except:
      Log.error("Unable to enable psyco as requested: ")

  # Run the main game loop.
  try:
    engine.ticksAtStart = pygame.time.get_ticks()
    while engine.run():
      pass
  except KeyboardInterrupt:
    Log.notice("Left mainloop due to KeyboardInterrupt.")
    # don't reraise

  # Restart the program if the engine is asking that we do so.
  if engine.restartRequested:
    Log.notice("Restarting.")
    engine.audio.close()
    try:
      # Extra arguments to insert between the executable we call and our
      # command line arguments.
      args = []
      # Figure out what executable to call.
      if hasattr(sys, "frozen"):
        if os.name == "nt":
          # When py2exe'd, sys.executable is the name of the EXE.
          exe = os.path.abspath(unicode(sys.executable, sys.getfilesystemencoding()))
        elif sys.frozen == "macosx_app":
          # When py2app'd, sys.executable is a Python interpreter copied
          # into the same dir where we live.
          exe = os.path.join(os.path.dirname(sys.executable), 'FoFiX')  # FIXME: don't hard-code "FoFiX" here
        else:
          raise RuntimeError, "Don't know how to restart when sys.frozen is %s" % repr(sys.frozen)
      else:
        # When running from source, sys.executable is the Python interpreter
        # being used to run the program.
        exe = sys.executable
        # Pass the optimization level on.
        if sys.flags.optimize > 0:
          args.append('-%s' % ('O' * sys.flags.optimize))
        args.append(__file__)
      os.execv(exe, [sys.executable] + args + sys.argv[1:])
    except:
      Log.error("Restart failed: ")
      raise

  # evilynux - MainMenu class already calls this - useless?
  engine.quit()
开发者ID:zelurker,项目名称:fofix,代码行数:104,代码来源:FoFiX.py

示例15: AnimationPlayerTest

# 需要导入模块: from GameEngine import GameEngine [as 别名]
# 或者: from GameEngine.GameEngine import quit [as 别名]
class AnimationPlayerTest(unittest.TestCase):
  # Simplest way to use the Animation player, use it as a Layer
  def testAnimationPlayerLayer(self):
    loop = 10
    config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
    self.e = GameEngine(config)
    animPlayer = AnimationPlayer(framerate, self.path, self.basename,
                                 (self.e.view.geometry[2],
                                  self.e.view.geometry[3]), loop = loop)
    print "Rendering as a GameEngine Layer for %d loops." % loop
    self.e.view.pushLayer(animPlayer)
    startTime = pygame.time.get_ticks()
    while not animPlayer.finished:
      self.e.run()
    stopTime = pygame.time.get_ticks()
    totalTime = stopTime - startTime
    print "nbrFrames: %d, nbrLoops: %d, Total time: %.02f s, Average fps: %.02f" % \
          (animPlayer.nbrFrames, loop, totalTime/1000.0, \
           (float(1000.0*animPlayer.nbrFrames*(loop+1)) / float(totalTime)))
    self.e.view.popLayer(animPlayer)
    self.e.quit()

  # Keep tight control over the Animation player
  def testAnimationPlayerSlave(self):
    loop = 5
    winWidth, winHeight = 800, 600
    pygame.init()
    flags = DOUBLEBUF|OPENGL|HWPALETTE|HWSURFACE
    pygame.display.set_mode((winWidth, winHeight), flags)
    animPlayer = AnimationPlayer(framerate, self.path, self.basename,
                                 (winWidth, winHeight), loop = loop)
    glViewport(0, 0, winWidth, winHeight) # Both required as...
    glScissor(0, 0, winWidth, winHeight)  # ...GameEngine changes it
    glClearColor(0, 0, 0, 1.)
    print "Rendering independently and fullscreen for %d loops." % loop
    clock = pygame.time.Clock()
    startTime = pygame.time.get_ticks()
    while not animPlayer.finished:
      ticks = clock.get_time()
      animPlayer.run(ticks)
      animPlayer.render()
      pygame.display.flip()
      clock.tick()
    stopTime = pygame.time.get_ticks()
    totalTime = stopTime - startTime
    print "nbrFrames: %d, nbrLoops: %d, Total time: %.02f s, Average fps: %.02f" % \
          (animPlayer.nbrFrames, loop, totalTime/1000.0,
           1000.0*animPlayer.nbrFrames*(loop+1) / float(totalTime))

    # Testing animation change
    # FIXME: another set of files would be more relevant (e.g. diff. resolution)
    loop = 5
    print "Let's go for another ride of %d loops." % loop
    animPlayer.loop = loop
    animPlayer.loadAnimation(self.path, self.basename)
    startTime = pygame.time.get_ticks()
    while not animPlayer.finished:
      ticks = clock.get_time()
      animPlayer.run(ticks)
      animPlayer.render()
      pygame.display.flip()
      clock.tick()
    stopTime = pygame.time.get_ticks()
    totalTime = stopTime - startTime
    print "nbrFrames: %d, nbrLoops: %d, Total time: %.02f s, Average fps: %.02f" % \
          (animPlayer.nbrFrames, loop, totalTime/1000.0,
           1000.0*animPlayer.nbrFrames*(loop+1) / float(totalTime))
    pygame.quit()

  # Grab the texture, use the CallList and do whatever we want with it;
  # We could also _just_ use the texture and take care of the polygons ourselves
  def testAnimationPlayerSlaveShowOff(self):
    winWidth, winHeight = 500, 500
    loop = 4
    pygame.init()
    flags = DOUBLEBUF|OPENGL|HWPALETTE|HWSURFACE
    pygame.display.set_mode((winWidth, winHeight), flags)
    animPlayer = AnimationPlayer(framerate, self.path, self.basename,
                                 (winWidth, winHeight), loop = loop)
    print "Rendering ourselves, doing what we want with the texture, for %d loops." % loop
    glViewport(0, 0, winWidth, winHeight) # Both required as...
    glScissor(0, 0, winWidth, winHeight)  # ...GameEngine changes it
    glClearColor(0, 0, 0, 1.)
    x, y = 0.0, 1.0
    fx, fy, ftheta = 1, 1, 1
    theta = 0.0
    time = 0.0
    clock = pygame.time.Clock()
    startTime = pygame.time.get_ticks()
    while not animPlayer.finished:
      ticks = clock.get_time()
      animPlayer.run(ticks)
      texture = animPlayer.getTexture()
      # Save and clear both transformation matrices
      glMatrixMode(GL_PROJECTION)
      glPushMatrix()
      glLoadIdentity()
      glMatrixMode(GL_MODELVIEW)
      glPushMatrix()
      glLoadIdentity()
#.........这里部分代码省略.........
开发者ID:Gamer125,项目名称:fofix,代码行数:103,代码来源:AnimationPlayerTest.py


注:本文中的GameEngine.GameEngine.quit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。