pygame库的学习

第一天:我学习了如何设置窗口和加载图片,以及加载音乐。这个库真的很有意思啊,打算py课设就拿这个写了。

代码:

import pygame
from sys import exit

pygame.init()
pygame.mixer.init()

background_image_filename = 'main_screen.jpg'
background_music_filename = 'tay.mp3'

pygame.mixer.music.load(background_music_filename)
pygame.mixer.music.play()

screen = pygame.display.set_mode([1500, 1000], 0, 32)
pygame.display.set_caption('Hello world')

background = pygame.image.load(background_image_filename).convert()

while True:
for event in pygame.event.get():
if event == pygame.QUIT:
exit()
screen.blit(background, (0, 0))
pygame.display.update()
posted @ 2020-01-08 07:55  SwiftAC  阅读(485)  评论(0编辑  收藏  举报