好了
import pygame
pygame.init()
screen = pygame.display.set_mode((640, 480))
img = pygame.transform.scale(pygame.image.load("bg.png"), screen.get_rect().center).convert_alpha()
for x in range(img.get_width()):
for y in range(img.get_height()):
if sum(img.get_at((x, y))[:3]) < 100:
img.set_at((x, y), (0, 0, 0, 0))
rect = img.get_rect()
rect.center = screen.get_rect().center
color_b = 255
state = 1
pos = list(rect.topleft)
size = list(rect.size)
clock = pygame.time.Clock()
running = True
while running:
clock.tick(30)
screen.fill((0, 0, 0))
if state == 1:
screen.fill((0, 0, color_b))
color_b -= 4
if color_b < 0:
state = 2
screen.blit(img, rect)
elif state == 2:
pos[0] -= 5
pos[1] -= 5
if pos[0] < 0:
pos[0] = 0
if pos[1] < 0:
pos[1] = 0
if pos[0] <= 0 and pos[1] <= 0:
state = 3
screen.blit(img, pos)
elif state == 3:
size[0] *= 0.9
size[1] *= 0.9
size[0] = int(size[0])
size[1] = int(size[1])
if size[0] < rect.width // 4:
state = 4
img = pygame.transform.scale(img, size)
screen.blit(img, (0, 0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.display.flip()
pygame.quit()
bg.png是你头像 |