Pygame 如何控制图片
Author: 刘敏 LiuMin EMAIL:liumin3000@gmail.com
怎么显示一张图片
screen = pygame.image.set_mode((800,600),0,32) 设置显示模式,返回 surface
image = pygame.image.load('pic.jpg') 加载图片,返回
surface screen.blit(image,(0,0)) 显示图片,位置(0,0),这个位置是该图片左上交的坐标
<script type=text/javascript> function isnumbered(obj) { return obj.childNodes.length && obj.firstChild.childNodes.length && obj.firstChild.firstChild.className == 'LineNumber'; } function nformat(num,chrs,add) { var nlen = Math.max(0,chrs-(''+num).length), res = ''; while (nlen>0) { res += ' '; nlen-- } return res+num+add; } function addnumber(did, nstart, nstep) { var c = document.getElementById(did), l = c.firstChild, n = 1; if (!isnumbered(c)) if (typeof nstart == 'undefined') nstart = 1; if (typeof nstep == 'undefined') nstep = 1; n = nstart; while (l != null) { if (l.tagName == 'SPAN') { var s = document.createElement('SPAN'); s.className = 'LineNumber' s.appendChild(document.createTextNode(nformat(n,4,' '))); n += nstep; if (l.childNodes.length) l.insertBefore(s, l.firstChild) else l.appendChild(s) } l = l.nextSibling; } return false; } function remnumber(did) { var c = document.getElementById(did), l = c.firstChild; if (isnumbered(c)) while (l != null) { if (l.tagName == 'SPAN' && l.firstChild.className == 'LineNumber') l.removeChild(l.firstChild); l = l.nextSibling; } return false; } function togglenumber(did, nstart, nstep) { var c = document.getElementById(did); if (isnumbered(c)) { remnumber(did); } else { addnumber(did,nstart,nstep); } return false; } </script> <script type=text/javascript> document.write('
Toggle line numbers '); </script>
1 #!/usr/local/bin/python
2 import pygame
3
4 pygame.init()
5 pic = 'bg.jpg'
6
7 screen =pygame.display.set_mode((600,600),0,32)
8 image = pygame