|
⇤ ← Revision 1 as of 2005-07-30 01:49:33
Size: 633
Comment:
|
Size: 1464
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| ## Please edit system and help pages ONLY in the moinmaster wiki! For more ## information, please see MoinMaster:MoinPagesEditorGroup. ## Please edit (or translate) system/help pages on the moinmaster wiki ONLY. ## For more information, please see MoinMaster:MoinPagesEditorGroup. ## Merci de n'éditer les pages systèmes et l'aide en ligne QUE sur MoinMaster ! ## Pour plus d'information, consultez MoinMaster:MoinPagesEditorGroup. ##master-page:HelpTemplate ##master-date:2005-01-10 22:19:05 #format wiki #language fr == Modèle des pages d'aide == Texte. |
== PyGame == === 简介 === * 简述:用于游戏制作 * 能力:有完备的控制、声音、显示模块,支持bmp,png等多种图像格式,自动载入Alpha通道,能显示复杂特效。 * 缺点:图像必须读入surface后显示,占用内存多,不适合制作大型游戏 * 官方站点: [http://www.pygame.org/] === 技巧 ==== |
| Line 14: | Line 9: |
| === Exemple === | === 代码段 === * 用一个surface填充另一个surface,很常用的功能,pygame里竟然没有,自己写一个。 |
| Line 16: | Line 12: |
| xxx }}} === Affichage === xxx |
#!python def fill_blit(source, dest, dRect, sRect = None ): if not sRect: sr = source.get_rect() else: sr = pygame.Rect(sRect) dr = pygame.Rect(dRect) for i in range(dr.height/sr.height): for j in range(dr.width/sr.width): dest.blit(source, (dr.x + j * sr.width, dr.y + i * sr.height), sr) if dr.width%sr.width != 0: left = dr.width%sr.width dest.blit(source, (dr.x + dr.width - left, dr.y + i * sr.height), (sr.x,sr.y,left,sr.height)) #填边 if dr.height%sr.height != 0: hleft = dr.height%sr.height for j in range(dr.width/sr.width): dest.blit(source, (dr.x + j * sr.width, dr.y + dr.height-hleft), (sr.x, sr.y, sr.width, hleft)) if dr.width%sr.width != 0: left = dr.width%sr.width dest.blit(source, (dr.x + dr.width - left, dr.y + dr.height-hleft), (sr.x, sr.y, left, hleft)) }}} |
PyGame
简介
- 简述:用于游戏制作
- 能力:有完备的控制、声音、显示模块,支持bmp,png等多种图像格式,自动载入Alpha通道,能显示复杂特效。
- 缺点:图像必须读入surface后显示,占用内存多,不适合制作大型游戏
官方站点: [http://www.pygame.org/]
=== 技巧 ====
代码段
- 用一个surface填充另一个surface,很常用的功能,pygame里竟然没有,自己写一个。
1 def fill_blit(source, dest, dRect, sRect = None ):
2 if not sRect:
3 sr = source.get_rect()
4 else:
5 sr = pygame.Rect(sRect)
6 dr = pygame.Rect(dRect)
7
8 for i in range(dr.height/sr.height):
9 for j in range(dr.width/sr.width):
10 dest.blit(source, (dr.x + j * sr.width, dr.y + i * sr.height), sr)
11 if dr.width%sr.width != 0:
12 left = dr.width%sr.width
13 dest.blit(source, (dr.x + dr.width - left, dr.y + i * sr.height), (sr.x,sr.y,left,sr.height))
14
15 #填边
16 if dr.height%sr.height != 0:
17 hleft = dr.height%sr.height
18 for j in range(dr.width/sr.width):
19 dest.blit(source, (dr.x + j * sr.width, dr.y + dr.height-hleft), (sr.x, sr.y, sr.width, hleft))
20 if dr.width%sr.width != 0:
21 left = dr.width%sr.width
22 dest.blit(source, (dr.x + dr.width - left, dr.y + dr.height-hleft), (sr.x, sr.y, left, hleft))
