Python-俄罗斯方块游戏3
【Python】用Python实现一个俄罗斯方块游戏俄罗斯方块游戏,使用Python实现,总共有350+行代码,实现了俄罗斯方块游戏的基本功能,同时会记录所花费时间,消去的总行数,所得的总分,还包括一个排行榜,可以查看最高记录。排行榜中包含一系列的统计功能,如单位时间消去的行数,单位时间得分等。附源码:from Tkinter import *from tkMessageBox import *import randomimport time#俄罗斯方块界面的高度HEIGHT = 18#俄罗斯方块界面的宽度WIDTH = 10ACTIVE = 1PASSIVE = 0TRUE = 1FALSE = 0root=Tk();root.title('Russia')class App(Frame): def __init__(self,master): Frame.__init__(self) master.bind('',self.Up) master.bind('',self.Left) master.bind('',self.Right) master.bind('',self.Down) #master.bind('',self.Space) master.bind('',self.Space) master.bind('',self.Play) master.bind('',self.Pause) self.backg="#%02x%02x%02x" % (120,150,30) self.frontg="#%02x%02x%02x" % (40,120,150) self.nextg="#%02x%02x%02x" % (150,100,100) self.flashg="#%02x%02x%02x" % (210,130,100) self.LineDisplay=Label(master,text='Lines: ',bg='black',fg='red') self.Line=Label(master,text='0',bg='black',fg='red') self.ScoreDisplay=Label(master,text='Score: ',bg='black',fg='red') self.Score=Label(master,text='0',bg='black',fg='red') #Display time self.SpendTimeDisplay=Label(master,text='Time: ',bg='black',fg='red') self.SpendTime=Label(master,text='0.0',bg='black',fg='red') self.LineDisplay.grid(row=HEIGHT-2,column=WIDTH,columnspan=2) self.Line.grid(row=HEIGHT-2,column=WIDTH+2,columnspan=3) self.ScoreDisplay.grid(row=HEIGHT-1,column=WIDTH,columnspan=2) self.Score.grid(row=HEIGHT-1,column=WIDTH+2,columnspan=3) #Display time self.SpendTimeDisplay.grid(row=HEIGHT-4,column=WIDTH,columnspan=2) self.SpendTime.grid(row=HEIGHT-4,column=WIDTH+2,columnspan=3) self.TotalTime=0.0 self.TotalLine=0;self.TotalScore=0 #Game over self.isgameover=FALSE #Pause self.isPause=FALSE #Start sel