資源簡介
Pygame游戲源代碼:俄羅斯方塊
包含代碼、圖片、聲音等所有資源,可直接運行

代碼片段和文件信息
#!/usr/bin/env?python
import?pygame
from?pygame.locals?import?*
from?pygame.time?import?*
from?sys?import?exit
from?random?import?*
from?shapebase?import?*
from?shapes?import?*
“““init?game“““
pygame.init()
screen?=?pygame.display.set_mode((800600)032)
pygame.display.set_caption(“Rusia?Block“)
icon?=?pygame.image.load(“py.jpg“)
pygame.display.set_icon(icon)
screen.fill((160160160))
“““some?value?use?in?main?loop“““
shapeslist?=?[[[0?for?a?in?range(4)]?for?b?in?range(20)]?for?c?in?range(16)]##all?droped?block
cur_pos?=?[[0?for?a?in?range(2)]?for?b?in?range(4)]#current?droping?block‘position4?block?[xy]
rgb?=?[0?for?a?in?range(3)]#current?droping?block‘s?rgb
bottom?=?True
right_pos?=?((0?for?a?in?range(2))?for?b?in?range(4))#current?droping?block‘rightshow?position
j?=?0
total_score?=?0
“““the?public?functions“““
def?newShape(cur_pos):
????“““create?a?new?random?shape“““
????i?=?randint(06)
????j?=?randint(03)
????rgb?=?[randint(0255)randint(0255)randint(0255)]
????if?i?==?0:#l2
????????if?j?==?0:
????????????cur_pos?=?[[719][718][717][617]]
????????elif?j?==?1:
????????????cur_pos?=?[[619][719][819][818]]
????????elif?j?==?2:
????????????cur_pos?=?[[719][819][718][717]]
????????elif?j?==?3:
????????????cur_pos?=?[[719][718][818][918]]
????????ashape?=?shapeL2(cur_posshapeslistrgb)
????if?i?==?1:#t
????????if?j?==?0:
????????????cur_pos?=?[[719][619][718][819]]
????????elif?j?==?1:
????????????cur_pos?=?[[719][718][717][818]]
????????elif?j?==?2:
????????????cur_pos?=?[[719][718][618][818]]
????????elif?j?==?3:
????????????cur_pos?=?[[719][718][717][618]]
????????ashape?=?shapeT(cur_posshapeslistrgb)
????if?i?==?2:#z
????????if?j?%?2?==?0:
????????????cur_pos?=?[[719][718][619][818]]
????????elif?j?%?2?==?1:
????????????cur_pos?=?[[719][718][618][617]]
????????ashape?=?shapeZ(cur_posshapeslistrgb)
????if?i?==?3:#l
????????if?j?==?0:
????????????cur_pos?=?[[719][718][717][817]]
????????elif?j?==?1:
????????????cur_pos?=?[[719][718][618][518]]
????????elif?j?==?2:
????????????cur_pos?=?[[719][619][718][717]]
????????elif?j?==?3:
????????????cur_pos?=?[[719][718][819][919]]
????????ashape?=?shapeL(cur_posshapeslistrgb)
????if?i?==?4:#z2
????????if?j?%?2?==?0:
????????????cur_pos?=?[[719][718][618][819]]
????????elif?j?%?2?==?1:
????????????cur_pos?=?[[719][718][818][817]]
????????ashape?=?shapeZ2(cur_posshapeslistrgb)
????if?i?==?5:#o
????????cur_pos?=?[[719][718][819][818]]
????????ashape?=?shapeO(cur_posshapeslistrgb)
????if?i?==?6:#i
????????if?j?%?2?==?0:
????????????cur_pos?=?[[719][718][717][716]]
????????elif?j?%?2?==?1:
????????????cur_pos?=?[[719][619][819][919]]
????????ashape?=?shapeI(cur_posshapeslistrgb)
????return?ashape?j
def?showChanged(screenrgbcur_pos):
????“““flesh?screen?while?k
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7976??2008-09-10?20:20??main.py
?????文件??????14289??2008-09-06?11:15??py.jpg
?????文件???????2929??2008-09-10?20:20??shapeba
?????文件???????3522??2012-07-25?14:53??shapeba
?????文件??????10139??2008-09-10?12:31??shapes.py
?????文件??????16376??2012-07-25?14:53??shapes.pyc
-----------?---------??----------?-----??----
????????????????55231????????????????????6
- 上一篇:圖書管理系統活動圖
- 下一篇:永磁同步電機矢量控制雙滑模模型參考 自適應系統轉速辨識
評論
共有 條評論