梦幻背景_绿色瀑布风景dynamic background waterfall parallax

"""动态背景_绿色瀑布风景waterfall parallax,这本来是一个scratch作品,现在用Python把它做一下."""

import pygame
from pygame.locals import *

width,height = 480,360
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("动态背景_绿色瀑布风景waterfall parallax www.lixingqiu.com")

pygame.mixer.init()
pygame.mixer.music.load("The Departure - Max Richter.mp3.wav")
pygame.mixer.music.play(-1,0)

costume1 = pygame.Surface((width,height))
costume1.fill((0,102,34))

costume2 = pygame.image.load("images/costume2.png").convert_alpha()
costume2_rect = costume2.get_rect()

costume3 = pygame.image.load("images/costume3.png").convert_alpha()
costume3_rect = costume3.get_rect()

costume4 = pygame.image.load("images/costume4.png").convert_alpha()
costume4_rect = costume4.get_rect()

costume5 = pygame.image.load("images/costume5.png").convert_alpha()
costume5_rect = costume5.get_rect()

costume6 = pygame.image.load("images/costume6.png").convert_alpha()
costume6_rect = costume6.get_rect()

costume7 = pygame.image.load("images/costume7.png").convert_alpha()
costume7_rect = costume7.get_rect()
 
clock = pygame.time.Clock()
running = True

while running:
    event = pygame.event.poll()
    if event.type == QUIT:running = False
    mx,my = pygame.mouse.get_pos()

    costume2_rect.centerx = width//2 +  (mx-width//2)/15 -100
    costume2_rect.centery = height//2 + (my-height//2)/15 - 50
    costume3_rect.centerx = width//2 +  (mx-width//2)/14 - 100
    costume3_rect.centery = height//2 + (my-height//2)/14 + 50
    costume4_rect.centerx = width//2 +  (mx-width//2)/11 
    costume4_rect.centery = height//2 + (my-height//2)/11 - 180
    costume5_rect.centerx = width//2 +  (mx-width//2)/10 
    costume5_rect.centery = height//2 + (my-height//2)/10  + 250
    costume6_rect.centerx = width//2 +  (mx-width//2)/5 
    costume6_rect.centery = height//2 + (my-height//2)/5  +100 
    costume7_rect.centerx = width//2 +  (mx-width//2)/2  - 200
    costume7_rect.centery = height//2 + (my-height//2)/2 + 200  

    # draw all images
    screen.blit(costume1,(0,0))
    screen.blit(costume2,costume2_rect)
    screen.blit(costume3,costume3_rect)
    screen.blit(costume4,costume4_rect)
    screen.blit(costume5,costume5_rect)
    screen.blit(costume6,costume6_rect)
    screen.blit(costume7,costume7_rect)
 
    pygame.display.update()
    clock.tick(30) 
    

pygame.quit()

动态背景_绿色瀑布风景waterfall parallax www.lixingqiu.com