- 帖子
- 14
- 精华
- 0
- 积分
- 84
- 阅读权限
- 20
- 注册时间
- 2013-8-10
- 最后登录
- 2014-1-13
|
回帖奖励 +1
点击鼠标在两个背景之间来回变换。。
# !/usr/bin/python
import pygame
from sys import exit
pygame.init()
screen = pygame.display.set_mode((600, 178), 0, 32)
pygame.display.set_caption("Hello, World!")
backgroud = pygame.image.load('pygame_back.png').convert()
backgroud1 = pygame.image.load('pygame_back1.png').convert()
temple = 0
backgroud_down = pygame.image.load('pygame_logo_bot.gif').convert()
backgroud_up = pygame.image.load('pygame_logo_top.gif').convert()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN:
temple = backgroud
backgroud = backgroud1
backgroud1 = temple
if event.type == pygame.QUIT:
pygame.quit()
exit()
screen.blit(backgroud, (0, 0))
screen.blit(backgroud_down, (0, 50))
screen.blit(backgroud_up, (485, 0))
pygame.display.update() |
|