示例#1
0
def _guiUpdate(reactor, delay):
    pyui.draw()
    if pyui.update() == 0:
        pyui.quit()
        reactor.stop()
    else:
        reactor.callLater(delay, _guiUpdate, reactor, delay)
    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):
        """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)
示例#4
0
文件: testView.py 项目: burito/PyUI
def run():
    done = 1
    frame = 0
    t = time.time()

    import testopt

    opts = testopt.parseCommandLine(800, 600, "dx")
    pyui.init(*opts)

    # w = pyui.widgets.ViewWindow(10, 10, 400, 300)
    # w.pack()

    terrainDetails = CreateTestTerrainDetails()
    terrain = PyUnseen.createTerrainRegion(terrainDetails)  # will take dictionary of stuff
    rootWorld = PyUnseen.getRootWorld()

    PyUnseen.addToWorld(rootWorld, terrain)  # just like any other object

    cameraPos = (-10, 6, -10)
    cameraDir = (45, -45, 0)

    view1 = PyUnseen.createView(rootWorld)  # will also take zMin, zMax?
    PyUnseen.setCameraParameters(view1, cameraPos, cameraDir)

    rootView = PyUnseen.getRootView()
    PyUnseen.setCameraParameters(rootView, cameraPos, cameraDir)

    while done:
        pyui.draw()
        done = pyui.update()

    print "done"
    pyui.quit()
 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 )
示例#6
0
文件: unittests.py 项目: burito/PyUI
 def run(self):
     counter = 0
     while counter < 20:
         pyui.draw()
         pyui.update()
         counter = counter + 1
         print counter
示例#7
0
文件: unittests.py 项目: burito/PyUI
 def testMove(self):
     v = pyui.viewer.Viewer(100,100,self)
     for i in range(0,100,5):
         v.moveto(i, i)
         pyui.draw()
         pyui.update()
     v.destroy()
示例#8
0
文件: testTree.py 项目: burito/PyUI
def run():
    done = 1
    frame = 0
    t = time.time()

    import testopt
    opts = testopt.parseCommandLine(640, 480)
    pyui.init(*opts)
    
    g = app()
    while done:
        pyui.draw()
        now = int(time.time())
        if now != t:
            print frame
            frame = 0
            t = now
        frame = frame + 1
        done = pyui.update()        


    print "done X"
    g.cleanup()
    pyui.quit()
    print "quit."
示例#9
0
文件: unittests.py 项目: burito/PyUI
 def testResize(self):
     b = pyui.widgets.Button("test")
     v = pyui.viewer.Viewer(100,100,b)
     for i in range(350,400,10):
         v.resize(i, i)
         pyui.draw()
         pyui.update()
     v.destroy()
示例#10
0
 def runMe(self):
     if not getDesktop().running:
         sys.exit()
     pyui.update()
     pyui.draw()
     self.frame = self.frame + 1
     now = time.time()
     if now - self.last >= 1:
         self.last = now
         print "FPS: %d" % self.frame
         self.frame = 0
示例#11
0
def run():
    """The main game loop."""
    done = 1
    global sx, sy
    pyui.init(sx, sy, "p3d")
    #pyui.core.setTheme(pyui.theme.uglyTheme())        
    g = game()
    while done:
        pyui.draw()
        done = pyui.update()

    pyui.quit()
示例#12
0
    def run(self):

        self.running = 1
        not_done = 1

        pyui.init(800, 600, fullscreen=1)

        for wrapper in wrappers:
            wrapper.prod()

        while not_done:
            pyui.draw()
            not_done = pyui.update()

        pyui.quit()
示例#13
0
文件: testWorld.py 项目: burito/PyUI
def run():
    done = 1
    frame = 0
    t = time.time()

    import testopt
    opts = testopt.parseCommandLine(800, 600)
    pyui.init(*opts)
    

    w = pyui.widgets.WorldWindow(50, 50, 400, 400)
    w.pack()
    
    while done:
        pyui.draw()
        done = pyui.update()

    print "done"
    pyui.quit()
示例#14
0
文件: boatTest.py 项目: burito/PyUI
    dbpool = adbapi.ConnectionPool("pyPgSQL.PgSQL", database="sean", host="localhost", port=5432)
    reflector = sqlreflector.SQLReflector(dbpool, [IdentityRow, PerspectiveRow])
    reflector._transPopulateSchema(None)
    
    # make sure we can be shut down on windows.
    main.addTimeout(tick, 0.5)

    # create the boat frame
    w = pyui.boat.BoatReflectorFrame(reflector, 0,0,790, 570)

    # run the main loop
    last = 0
    frame = 0
    try:
        while pyui.update():
            pyui.draw()
            main.iterate()
            frame += 1
            now = time.time()
            if now - last > 2:
                print "FPS: ", int(frame/2)
                frame=0
                last=now
    except:
        print "ERROR:"
        traceback.print_exc()

    # done. quit now.
    pyui.quit()
    reactor.stop()
    main.iterate()