To scale an image with pygame is easy:
- load the image
- get the size of the screen
- blit the image on the screen using pygame.transoform.scale passing the image and the dimension you want the image to be scaled to in a tuple
import pygame # SCALE AN IMAGE TO FIT THE SCREEN pygame.init() screen = pygame.display.set_mode((600, 500)) bg = pygame.image.load("image.png").convert_alpha() sw, sh = screen.get_size() while True: screen.blit(pygame.transform.scale(bg, (sw, sh)),(0, 0)) if pygame.event.get(pygame.QUIT): break pygame.display.update() pygame.quit()
Live coding video
xds
Subscribe to the newsletter for updates
Tkinter templates
My youtube channel
Twitter: @pythonprogrammi - python_pygame