一个蓝天白云太阳动态场景,配的音乐效果不错!
以下是部分代码预览:
"""动态背景_蓝天绿地太阳云朵户外场景动画演示""" __author__ = "李兴球" __date__ = "2019/6/3" __website__ = "www.lixingqiu.com" import time import pygame from random import * from pygame.locals import * class Sun: def __init__(self,images,position): self.images = images self.index = 0 # 造型索引 def update(self): pass def set_costume(self,index): """设置造型""" self.image = self.images[index] class Cloud(pygame.sprite.Sprite): def __init__(self,images,group,screen_width): super().__init__() pass if __name__ == "__main__": width,heigt = 480,360 screen = pygame.display.set_mode((480,360)) pygame.display.set_caption("动态背景_蓝天绿地太阳云朵户外场景动画演示www.lixingqiu.com") pygame.mixer.init() pygame.mixer.music.load("Yonderboi - Pabadam.wav") pygame.mixer.music.play(-1,0) background = pygame.image.load("images/background.png") sun = Sun(sun_images,(150,50)) clock = pygame.time.Clock() running = True while running: event = pygame.event.poll() if event.type == QUIT: running = False if randint(1,100) == 1 : Cloud(cloud_images,cloud_group,width ) pygame.display.update() clock.tick(30) pygame.quit()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)