pygame系列_游戏窗口显示策略
在这篇blog中,我将给出一个demo演示:
当我们按下键盘的‘f’键的时候,演示的窗口会切换到全屏显示和默认显示两种显示模式
并且在后台我们可以看到相关的信息输出:

上面给出了一个简单的例子,当然在pygame的官方文档中有对显示策略的更权威的说明:
http://www.pygame.org/docs/ref/display.html#pygame.display.set_mode

'''
pygame.FULLSCREEN create a fullscreen display
pygame.DOUBLEBUF recommended for HWSURFACE or OPENGL
pygame.HWSURFACE hardware accelerated, only in FULLSCREEN
pygame.OPENGL create an opengl renderable display
pygame.RESIZABLE display window should be sizeable
pygame.NOFRAME display window will have no border or controls
'''

==========================================================
代码部分:
==========================================================

1 #pygame fullscreen
2
3 import os, pygame
4 from pygame.locals import *
5 from sys import exit
6
7 '''
8 pygame.display.set_mode():
9 pygame.FULLSCREEN create a fullscreen display
10 pygame.DOUBLEBUF recommended for HWSURFACE or OPENGL
11 pygame.HWSURFACE hardware accelerated, only in FULLSCREEN
12 pygame.OPENGL create an opengl renderable display
13 pygame.RESIZABLE display window should be sizeable
14 pygame.NOFRAME display window will have no border or controls
15 '''
16
17 __author__ = {'name' : 'Hongten',
18 'mail' : 'hongtenzone@foxmail.com',
19 'blog' : 'http://www.cnblogs.com/hongten',
20 'Version' : '1.0'}
21
22 BG_IMAGE = 'bg.png'
23 SCREEN_DEFAULT_SIZE = (500, 500)
24 pygame.init()
25
26 #create the image path
27 bg_path = os.path.join('data', BG_IMAGE)
28 if not os.path.exists(bg_path):
29 print('The BackGround Image does not exist!')
30
31 screen = pygame.display.set_mode(SCREEN_DEFAULT_SIZE, 0, 32)
32 bg = pygame.image.load(bg_path).convert()
33
34 #full screen flag
35 full_screen = False
36
37 while 1:
38 for event in pygame.event.get():
39 if event.type == QUIT:
40 exit()
41 if event.type == KEYDOWN:
42 #when press the 'f',then change the screen display model
43 if event.key == K_f:
44 full_screen = not full_screen
45 if full_screen:
46 print('Open the Fullscreen model!')
47 else:
48 print('Open the Default model!')
49 if full_screen:
50 #full screen display model
51 screen = pygame.display.set_mode(SCREEN_DEFAULT_SIZE, FULLSCREEN, 32)
52 else:
53 #default model
54 screen = pygame.display.set_mode(SCREEN_DEFAULT_SIZE, 0, 32)
55
56 screen.blit(bg, (0, 0))
57 pygame.display.update()

pygame系列_游戏窗口显示策略的更多相关文章
- pygame系列_原创百度随心听音乐播放器_完整版
程序名:PyMusic 解释:pygame+music 之前发布了自己写的小程序:百度随心听音乐播放器的一些效果图 你可以去到这里再次看看效果: pygame系列_百度随心听_完美的UI设计 这个程序 ...
- pygame系列_小球完全弹性碰撞游戏_源码下载
之前做了一个基于python的tkinter的小球完全碰撞游戏: python开发_tkinter_小球完全弹性碰撞游戏_源码下载 今天利用业余时间,写了一个功能要强大一些的小球完全碰撞游戏: 游戏名 ...
- pygame系列_小球完全弹性碰撞游戏
之前做了一个基于python的tkinter的小球完全碰撞游戏: 今天利用业余时间,写了一个功能要强大一些的小球完全碰撞游戏: 游戏名称: 小球完全弹性碰撞游戏规则: 1.游戏初始化的时候,有5个不同 ...
- pygame系列_游戏中的事件
先看一下我做的demo: 当玩家按下键盘上的:上,下,左,右键的时候,后台会打印出玩家所按键的数字值,而图形会随之移动 这是客观上面存在的现象. 那么啥是事件呢? 你叫我做出定义,我不知道,我只能举个 ...
- pygame系列_箭刺Elephant游戏
这个游戏原名为:Chimp,我们可以到: http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html 获取到源码和详细的源码讲解 下面是我对游戏 ...
- pygame系列_箭刺Elephant游戏_源码下载
这个游戏原名为:Chimp,我们可以到: http://www.pygame.org/docs/tut/chimp/ChimpLineByLine.html 获取到源码和详细的源码讲解 下面是我对游戏 ...
- pygame系列_弹力球
这是pygame写的弹力球 运行效果: ======================================================== 代码部分: ================= ...
- pygame系列_第一个程序_图片代替鼠标移动
想想现在学校pygame有几个钟了,就写了一个小程序:图片代替鼠标移动 程序的运行效果: 当鼠标移动到窗口内,鼠标不见了,取而代之的是图片..... ========================= ...
- pygame系列_百度随心听_完美的UI设计
这个程序的灵感来自于百度随心听 下面是我的程序截图: 说明: 动作按钮全部是画出来的,没有用到任何图片 用到图片的只有:背景,歌手图片,作者图片 代码正在调试中.... 如果你鼠标移动到黄色小圆里面, ...
随机推荐
- XP教育网用户免费上网
本文针对 XP 教育网用户免费上网,其他系统未作测试.若有疑问百度空间留言 http://hi.baidu.com/itas109 http://blog.csdn.net/itas109 步骤 ...
- 医院API免费接口的公布
医院通网(http://hospital.yi18.net) 站点上站快两个月了,基本已经稳定,尽管还有非常多小bug,但还是不影响大局.抱着数据开放和共享的理念,医院大全API接口 (http:// ...
- alv行可编辑时带出描述
ALV显示可以编辑的状态下可以带出描述信息等,比如维护表程序输入公司代码时需要带出公司代码的描述,这时就需要通过下面事件来触发 定义一个类: CLASS lcl_event_receiver DEFI ...
- CImageList使用指南
在MFC中CImageList类封装了图像列表控件的功能,图像列表是一个具有相同大小的图像(可以是不同类型)的集合,其主要用于应用程序中大规模图标的存储.该控件是不可见的,通常与其它如CListBox ...
- mysql sql执行顺序
<pre name="code" class="html">mysql> explain select * from (select * fr ...
- win7下不能收到窗口hook消息的问题
win7下由于UIPI的限制, 高权限进程无法收到底权限进程发来的消息, 因此对窗口消息hook时无法接收到消息,解决办法是在调用SetWindowsHookEx之前先调用ChangeWindowMe ...
- android中,如果使用imageButton可以在drawable 中设置一个selector,但是imageView设置不起作用
android中,如果使用imageButton可以在drawable 中设置一个selector,但是imageView设置不起作用,只要把Imageview的src给去掉就成了,src捕获了bac ...
- LeetCode——Count and Say
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221 ...
- (76) Clojure: Why would someone learn Clojure? - Quora
(76) Clojure: Why would someone learn Clojure? - Quora ★ Why would someone learn Clojure? Edit
- sharepoint 2010 显示和隐藏Ribbon区域条
在sharepoint 2010的页面中,我们在页面的最上方,有一条深灰色的Ribbon工具栏,如下图,这里可以通过下面的脚本,做一些脚本,来控制它的隐藏和显示. 最后把这些脚本,放在v4.maste ...