Ticket #8289: bounce.patch

File bounce.patch, 1.5 kB (added by cscott, 6 years ago)

Don't busy-wait in Bounce

  • .activity/bounce.py

    diff -ruHp Bounce.activity/bounce.py Bounce2.activity/bounce.py
    old new  
    12871287        # Initialize the FPS counter & limiter. 
    12881288        self.lastclock = time.time() 
    12891289        game.fps = 0.0 
    1290         self.limitfps = 30.0 # 30fps is what the XO can currently handle. 
     1290        self.limitfps = 20.0 # 20fps is what the XO can currently handle. 
    12911291 
    12921292        # Get current player info for the scores table. 
    12931293        self.pservice = presenceservice.get_instance() 
     
    16321632        game.sequence.update() 
    16331633        self.drawarea.queue_draw() 
    16341634 
    1635         # Limit framerate. 
     1635        # Compute framerate. 
    16361636        diff = float(time.time() - self.lastclock) 
    16371637        if diff > 0: 
    16381638            game.fps = 1.0 / diff 
    1639         while time.time() - self.lastclock < 1.0/self.limitfps: 
    1640             pass 
    16411639        self.lastclock = time.time() 
    16421640 
    16431641        return True 
     
    16451643    def mainloop (self): 
    16461644        """Runs the game loop.  Note that this doesn't actually return until the activity ends.""" 
    16471645        self.running = True 
     1646        clock = pygame.time.Clock() 
    16481647        while self.running: 
     1648            clock.tick(self.limitfps) 
    16491649            self.tick() 
    16501650            while gtk.events_pending(): 
    16511651                gtk.main_iteration(False)