《Python俄罗斯方块源码》由会员分享,可在线阅读,更多相关《Python俄罗斯方块源码(10页珍藏版)》请在人人文库网上搜索。
1、Python俄罗斯方块源码诺基亚S60v3手机PY平台专用代码作者:千年臭虫from graphics import*import random,e32,appuifwcn=lambda x: x.decode(u8)#_______________________def juxing(t1,t2,s,x=1,y=1):#参数:宽/高/切角大小/坐标X/坐标Ya1,d1=1+x,t1+xc1=t1-s+xb1=s+1+xa2,d2=1+y,t2+yc2=t2-s+yb2=s+1+ylist1=b1,a2,c1,a2,d1,b2,d1,c2,c1,d2,b1,d2,a1,c2,a1,b2retu。
2、rn list1#_____________________def Masks():#蒙罩生成函数img=Image.new(15,15),L)img2=Image.new(15,15),L)img3=Image.new(15,15),L)img2.clear(0)img3.clear(0)biao=juxing(14.5,14.5,0.9,0.3,0.3)img.polygon(biao),0xff5fff,0xff5fff)img2.polygon(biao),0xffffff,0xffffff)img3.polygon(biao),0xffffff,0xffffff)biao=juxin。
3、g(12.8,12.8,2)img.polygon(biao),0xf9ff9f,0x9fff9f,width=1)img3.polygon(biao),0x0,0x0)for i in range(7):RGB=(105+i*20,105+i*20,115+i*20)img.line(2,7.5-i,13,7.5-i),(RGB)img.line(2,7.5+i,13,7.5+i),(RGB)return (img,img2,img3)def Images(mask1,se2):#生成彩色画布函数img=Image.new(15,15)img2=Image.new(15,15)img2.cl。
4、ear(0xffffff)img.clear(se2)for i in range(8):img.arc(3+i*0.7,5,3+i,10),0,2,(255-i*10,200-i*10,0+i*20)img.blit(img2,target=(0,0),source=(0,0,15,15),mask=mask1)return img#_______________________def FkCen(ll,S):#方块层函数for i in range(2):for j in range(len(ll):llj0+i=1llj12+i=1if j15):returnf0=1,1,1,1,1,1。
5、,1,1,1,0f1=1,1,1,1,1,1,1,1,0,0f2=1,1,1,1,1,1,1,0,0,0Fk=f0,f1,f2for i in range(21,0,-1):S-=1v=random.randint(0,2)ls=Fkvrandom.shuffle(ls)#乱序for j in range(10):llij+2=lsjif S0):#计算分值v=len(n)-1num=100,300,750,1500 fen1+=numvfen2+=len(n)#- n.sort()while (len(n)0):#游戏活动区域切片img=Image.new(150,300)img.clear。
6、(0)ce=0for i in range(20,0,-1): if i=n0-1:ce+=15img.blit(ImgBg,target=(0,i*15-15),source=(2,285-ce,152,300-ce)ce+=15del n0ImgBg.blit(img,target=(2,0)s.cs.blit(ImgBg)e32.ao_sleep(0.08)#_____________________def Key_z(s,e):#按键中转Key_zz=s.Key0,s.Key1,s.Key2Key_zzs.k(e)#_____________________def Key0(s,e):。
7、#Nonepass#_____________________ def Key1(s,e): s.e=ewhile s.escancode=17and s.etype=1:#下方向ImgLs.blit(ImgBg)if(s.a.go_next()!=1): breaks.draw_w()e32.ao_sleep(0.001)while s.escancode=167 and s.etype=1 and s.AN4):#结束游戏判断s.Over()breaks.sui=S1s.a=bS1=random.randint(0,6)b=tu(S1) b.show(ImgJiS1,mask2,ImgBg。
8、,124,250)#画NEXT方块for i in range(22):s.TIME=0s.k=1s.AN=0ImgLs.blit(ImgBg)s.draw_w()if(s.SD-s.TIME0):Times=s.SD-s.TIMEelse:Times=0.001 e32.ao_sleep(Times)if(s.a.go_next()!=1):#方块不能往下降落处理s.a.cha()s.a.show(ImgJis.sui,mask2,ImgBg)s.check()fen0=fen1/10000+levels.SD=0.35-0.38/13*fen0s.draw_pin()break#_____。
9、______________def Go_game():pass#_______________________WIDTH,HEIGHT=240,320ImgBg=Image.new(WIDTH,HEIGHT)ImgLs=Image.new(ImgBg.size)img_lan=Image.new(WIDTH/2.85,HEIGHT)R,G,B=100,200,190for i in range(100):RGB=(R+i,G-i,B-i)img_lan.rectangle(0+i,0,1+i,HEIGHT),(RGB),(RGB),width=2)FK_SUM=0 for i in rang。
10、e(14)for j in range(24)level=5#初始关卡cen=0#方块初始层数touying=1#投影开关(0/1)fen=0,0,0#关卡/分数/行数color1=0xffffff#隐形方块边线颜色#颜色参数集ColorJi=(0xff00ff,0x,0x9f009f,0x8f6fff,0x0000ff,0xff0000,0x009f00,color1,0xff008f)mask1,mask2,mask3=Masks()ImgJi=#彩色画布列表for i in range(9):ImgJi.append(Images(mask1,ColorJii)FkCen(FK_SUM,cen)app=App()#_______________________。