Esempio n. 1
0
File: run.py Progetto: colshag/ANW
    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)
Esempio n. 2
0
def _guiUpdate(reactor, delay):
    pyui.draw()
    if pyui.update() == 0:
        pyui.quit()
        reactor.stop()
    else:
        reactor.callLater(delay, _guiUpdate, reactor, delay)
Esempio n. 3
0
    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):
        """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) )
Esempio n. 5
0
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 )
Esempio n. 7
0
 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()
Esempio n. 8
0
 def run(self):
     counter = 0
     while counter < 20:
         pyui.draw()
         pyui.update()
         counter = counter + 1
         print counter
Esempio n. 9
0
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."
Esempio n. 10
0
def _guiUpdate(reactor, delay):
    pyui.draw()
    if pyui.update() == 0:
        pyui.quit()
        reactor.stop()
    else:
        reactor.callLater(delay, _guiUpdate, reactor, delay)
Esempio n. 11
0
    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)
Esempio n. 12
0
    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))
Esempio n. 13
0
 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()
Esempio n. 14
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
Esempio n. 15
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
Esempio n. 16
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()
Esempio n. 17
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()
Esempio n. 18
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()
Esempio n. 19
0
File: app.py Progetto: colshag/ANW
    def run(self):
        """Run the game through a loop"""
        running = 1
        frames = 0
        counter = 0
        lastFrame = time.time()
        endFrame = time.time()
        delaySec = 0.0

        while running:
            pyui.draw()
            if pyui.update():
                if self.intervalValue == 0:
                    interval = time.time() - endFrame
                else:
                    interval = self.intervalValue
                endFrame = time.time()
                if self.game.update(interval) == 0:
                    running = 0
            else:
                running = 0
            time.sleep(delaySec)
            # track frames per second
            frames += 1
            counter += 1

            # calculate FPS
            if endFrame - lastFrame > 1.0:
                FPS = counter
                counter = 0
                lastFrame = endFrame
                self.log.info('FPS: %2d, INTERVAL: %s' % (FPS, interval))
                if FPS > self.desiredFPS:
                    if delaySec == 0 or (FPS - self.desiredFPS) > 10:
                        delaySec = (1.0 / self.desiredFPS - 1.0 / FPS)
                    else:
                        delaySec *= 1.05

                elif FPS < self.desiredFPS:
                    if delaySec > 0.001:
                        delaySec /= 2
                    else:
                        delaySec = 0

                #print "delaySec: ",delaySec

            if self.game.mode and running == 1:
                self.game.mode.onKey()
Esempio n. 20
0
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()
Esempio n. 21
0
    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()