kwonsungmin
kwonsungmin

Reputation: 21

How can I make the picture run perfectly on the screen?

I want to make the background perfect for the running screen, but the vertical axis of the picture doesn't stretch even if I keep changing it in the code. How can I get it right?

import pygame
SCREEN_WIDTH = 500
SCREEN_HEIGHT  = 600
pygame.init()
SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("pygame test")

screen=  pygame.image.load("그림.png")
SCREEN.blit(screen,(0,100))
SCREEN.blit(player, player_Rect)
pygame.display.flip()

if i add screen=pygame.transform.scale(500,600) this code print black screen

Upvotes: 2

Views: 24

Answers (1)

Rabbid76
Rabbid76

Reputation: 210928

pygame.transform.scale() takes two arguments, the source surface and a tuple with the size of the new and scaled surface:

screen=pygame.transform.scale(500,600)

screen = pygame.transform.scale(screen, (500, 600))

Scale the surface immediately after loading it:

screen = pygame.transform.scale(pygame.image.load("그림.png").convert_alpha(), (500, 600))

Upvotes: 1

Related Questions