You have to code it yourself.
Draw your game not directly on the display surface, but on an intermediate one that you can resize to the display surface's size.
Here's a simple example:
import pygame
from pygame.locals import *
def main():
pygame.init()
screen = pygame.display.set_mode((400, 300),HWSURFACE|DOUBLEBUF|RESIZABLE)
game_screen = screen.copy()
pic = pygame.surface.Surface((50, 50))
pic.fill('dodgerblue')
while True:
for event in pygame.event.get():
if event.type == QUIT:
return
elif event.type == VIDEORESIZE:
ratio = game_screen.get_rect().width / game_screen.get_rect().height
new_size = event.size[0], int(event.size[0] / ratio)
screen = pygame.display.set_mode(new_size, HWSURFACE|DOUBLEBUF|RESIZABLE)
game_screen.fill('black')
game_screen.blit(pic, (100, 100))
screen.blit(pygame.transform.scale(game_screen, screen.get_rect().size), (0, 0))
pygame.display.flip()
main()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…