python game3练习

来源:互联网 发布:日语口语网络课程 编辑:程序博客网 时间:2024/05/22 16:49
#! /usr/bin/env python2.7# -*- coding:utf-8 -*-#File:PG3.py#Date:2013-7-2#Author:wangyubackground_image_filename='8wxpython.jpg'import pygamefrom pygame.locals import *from sys import exitpygame.init()screen =pygame.display.set_mode((1640,980),0,32)background=pygame.image.load(background_image_filename).convert()Fullscreen=Falsewhile True:    for event in pygame.event.get():        if event.type ==QUIT:            exit()        if event.type == KEYDOWN:            if event.key == K_f:                Fullcsreen= not Fullscreen                if Fullscreen:                    screen=pygame.display.set_mode((1248,960),FULLSCREEN,32)                else:                    screen=pygame.display.set_mode((640,480),0,32)    screen.blit(background,(0,0))    pygame.display.update()

这时一个控制窗口大小的简单程序,其中通过按f键就能从大屏切换到小屏,下图为大图

下面为按过f键之后的界面.

这些代码的最初位置为:http://eyehere.net/2011/python-pygame-novice-professional-3/

里面有最详细的解释,只是里面的代码有点为题,我进行了改动

感谢原作者

原创粉丝点击