- 帖子
- 36
- 精华
- 0
- 积分
- 243
- 阅读权限
- 30
- 注册时间
- 2013-8-20
- 最后登录
- 2015-9-6
|
多张图片随机切换:- # -*- coding: utf-8 -*-
- import pygame
- from sys import exit
- from pygame import *
- import random
- pygame.init()
- screen = pygame.display.set_mode((630, 300), 0, 32)
- pygame.display.set_caption("hello world")
- bg1 = image.load('bg.png').convert()
- bg2 = image.load('bg2.jpg').convert()
- bg3 = image.load('bg3.jpg').convert()
- bgcolor = [bg1, bg2, bg3]
- target = True
- bg = bg1
- while 1:
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- exit()
- if event.type == MOUSEBUTTONDOWN:
- bg = random.choice(bgcolor)
- screen.blit(bg, (0,0))
- pygame.display.update()
复制代码 |
|