文档介绍:Python俄罗斯方块游戏
Python俄罗斯方块游戏
Python俄罗斯方块游戏
【Python 】用 Python 实现一个俄罗斯方块游戏
俄罗斯方块游戏,使用 Python 实现,总合有 350+行代码,实现了俄罗斯方块游戏的根本功
能,同时会记录所开销时间,消去的总行数,所得的总分,还包括一个排行榜,可以查察最
高记录。
排行榜中包括一系列的统计功能,如单位时间消去的行数,单位时间得分等。
附源码:
from Tkinter import *
from tkMessageBox import *
import random
import time
#俄罗斯方块界面的高度
HEIGHT = 18
#俄罗斯方块界面的宽度
WIDTH
= 10
ACTIVE
= 1
PASSIVE = 0
TRUE
= 1
FALSE
= 0
root=Tk();('Russia')
class App(Frame):
def __init__(self,master):
(self)
('<Up>',
('<Left>',
('<Right>',
('<Down>',
#('<Down>',
('<space>',
('<Control-Shift-Key-F12>',
('<Key-F6>',
="#%02x%02x%02x" % (120,150,30)
="#%02x%02x%02x" % (40,120,150)
="#%02x%02x%02x" % (150,100,100)
="#%02x%02x%02x" % (210,130,100)
=Label(master,text='Lines: ',bg='black',fg='red')
=Label(master,text='0',bg='black',fg='red')
=Label(master,text='Score: ',bg='black',fg='red')
=Label(master,text='0',bg='black',fg='red')
#Display time
=Label(master,text='Time: ',bg='black',fg='red')
=Label(master,text='',bg='black',fg='red')
#Display time
=
=0;=0
#Game over
=FALSE
#Pause
=FALSE
#Start
=FALSE
=[];=[]
Python俄罗斯方块游戏
Python俄罗斯方块游戏
Python俄罗斯方块游戏
r=0;c=0
Python俄罗斯方块游戏
Python俄罗斯方块游戏
Python俄罗斯方块游戏
for k in range(4*4):
LN=Label(master,text=' ',bg=str,fg='white',relief=FLAT,bd=4)
(row=r,column=WIDTH+c,sticky=N+E+S+W)
c=c+1
if c>=4:
r=r+1;c=0
=[]
=[];=[]
=[];=[]
row=0;col=0
for i in range(HEIGHT*WIDTH):
L=Label(master,text=' ',bg=str,fg='white',relief=FLAT,bd=4)
(row=row,column=col,sticky=N+E+S+W)
=row;=col;=PASSIVE
col=col+1
if col>=WIDTH:
row=row+1;col=0
=[];=[]
#file
fw=open('','a')
()
hasHead=FALSE
f=open('','r')
if (5)=='score':