0

I have been attempting a shooter game in pygame but I have come across some difficulties with the fps. As I play the game the majority of the time the fps is clearly much less than what I have set it too. It doesn't seem to go above 50. If I test a high fps (100) it seems to go less than 50 fps. I appreciate any help, thanks.

        screen.fill((0,0,0))
        screen.blit(space,(0,0))
        if activate == False:
            pygame.draw.rect(screen,(0,0,0),(x+50,590,10,50))
        elif activate == True:
            y1-=5
            pygame.draw.rect(screen,red,(x1,y1,10,50))
        screen.blit(ship,(x,550))
        if hit == False:
            screen.blit(tie,(x2,y2))
            screen.blit(tie,(x3,y3))
        screen.blit(messenger(str(score),green,72),(20,20))
        pygame.draw.rect(screen,healthColour,(600,0,health*4,20))
        screen.blit(messenger("Health:",green,20),(525,-5))
        pygame.display.update()
        clock.tick(50)
pygame.quit()

I think it could be due to my images. The 'space' image (background) is my primary concern as when I remove it the code runs smoothly. It is very high definition. I do not think it is because of my computer performance(i5 processor), after all it is a very basic program.

ship = pygame.transform.scale(pygame.image.load("xwing.png"),(100,100))
space = pygame.transform.scale(pygame.image.load("space.jpg"),(1000,700))
tie = pygame.transform.scale(pygame.image.load("tie.png"),(100,100))
  • Please provide a [minimal, complete and verifable example](http://stackoverflow.com/help/mcve), otherwise we can't test the provided code and find the error. – skrx May 06 '17 at 02:38
  • Pygame is getting pretty old now, and asking 100fps of it is pretty unrealistic. I know that you can expect high fps from games that you play, but these games won't be written using Pygame! – Ari Cooper-Davis May 06 '17 at 20:26
  • We can't help you if you post only such a short code snippet. Read the [mcve](http://stackoverflow.com/help/mcve) page again and then post a complete example. – skrx May 07 '17 at 07:34
  • BTW, you should always use the `convert` (`convert_alpha` for images with transparency) method to improve the blit performance of surfaces. `ship = pygame.transform.scale(pygame.image.load("xwing.png").convert(),(100,100))` – skrx May 07 '17 at 07:50
  • `clock.tick` is for slowing down the game when it goes to fast. It will in no way speed up the game. If you are getting such low fps it means that your code is just slow (btw: in the code, you posted you are blocking the fps at 50 frames per second. – Joseph Chotard May 07 '17 at 13:30

0 Answers0