0

I am making a simple platformer game. For it to run smoothly it needs to run at about <110 fps. When the game is at 640 by 512 it runs around there, however when I scale it up to 1280 by 1024 it halves my frame rate How do I fix this? and why does this happen?

NOTE: this is not my full code but snippets of code where blitting/ resizing happens.

resized = True
screen = display.set_mode((640, 512), RESIZABLE)
blitSurface = Surface((1280, 1024)).convert()

while: true:
  for events in event.get():
    if events.type == VIDEORESIZE: resized = True

  blitSuface.blit(bg[0][0], bg[0][1])
  blitSuface.blit(bg[1][0], bg[1][1])
  blitSuface.blit(bg[2][0], bg[2][1])

 if resized:
    fit_to_rect = blitSuface.get_rect().fit(screen.get_rect())
    fit_to_rect.center = screen.get_rect().center
 scaled = transform.smoothscale(blitSuface, fit_to_rect.size)

 resized = False

  • 1
    That makes sense - you're rendering more pixels per frame, so you'd expect the framerate to decrease. As long as you're [correctly scaling](https://stackoverflow.com/questions/35617246/setting-a-fixed-fps-in-pygame-python-3) updates based on time elapsed between frames, a lower framerate shouldn't be an issue. – superhawk610 Mar 24 '21 at 07:55
  • 1
    Check [this SO answer](https://stackoverflow.com/a/35620064/885098) and read the docs on [pygame.time.Clock](https://www.pygame.org/docs/ref/time.html#pygame.time.Clock.tick). – superhawk610 Mar 24 '21 at 09:15
  • Thank you so much both of you!! it works better however its still looks very choppy. – MottledKarma517 Mar 24 '21 at 13:19

0 Answers0