[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] pygame 1.8 - problem with framerate



Hi.

I updated the version of pygame, 1.7.1 to 1.8, and I had problem with that. My game started to become very slow, only by exchanging version. I was looking to see what was happening and saw that the fps was very low. I created a simple code to test and I saw that for the same code, ran on both versions, there is a big difference in FPS. What may be happening?

Thank you.


The code that I used for test is below:

import pygame

class Game:
       screen = None
       screen_size = None
       run = True

       def __init__( self, size, fullscreen):
               pygame.init()
               flags = pygame.DOUBLEBUF
               if fullscreen:
                       flags = (pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE)
               self.screen = pygame.display.set_mode( size, flags )

       def handle_events( self ):
               for event in pygame.event.get():
                       if ((event.type == pygame.KEYDOWN)or(event.type == pygame.KEYUP)):
                               if (event.key == pygame.K_ESCAPE):
                                       self.run = False

       def loop( self ):
               clock = pygame.time.Clock()
               while (self.run):
                       clock.tick()
                       print clock.get_fps()
                       self.screen.fill((255,255,255))
                       self.handle_events()
                       pygame.display.flip()


game = Game((1024,768), 1)
game.loop()