资源描述:
《3D俄罗斯方块源码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1.package{2.importflash.display.Sprite;3.importflash.text.TextField;4.importflash.events.Event;5.importflash.events.KeyboardEvent;6.importflash.utils.getTimer;7.8.importorg.papervision3d.materials.*;9.importorg.papervision3d.materials.utils.*;10.importorg.papervision3d.
2、materials.shadematerials.FlatShadeMaterial;11.importorg.papervision3d.lights.PointLight3D;12.importorg.papervision3d.objects.*;13.importorg.papervision3d.objects.primitives.*14.importorg.papervision3d.view.*;15.importorg.papervision3d.scenes.Scene3D;16.17.[SWF(backgroun
3、dColor="0x000000",frameRate="24")]18.19.publicclassTetrisextendsBasicView{20.privateconstW:int=10;21.privateconstH:int=20;22.privateconstUNIT:int=16;23.privateconstCOLOR:Array=[0x000000,0x00FFFF,0xFFFF00,0x22FF22,0xFF2222,0x4444FF,0xFF8844,0xFF22FF];1.privateconstPAT:Ar
4、ray=[2.[[1,1,1,1]],3.[[0,2,0],[2,2,2]],4.[[3,3,0],[0,3,3]],5.[[0,4,4],[4,4,0]],6.[[5,5],[5,0],[5,0]],7.[[6,6],[0,6],[0,6]],8.[[7,7],[7,7]]9.];10.privateconstSPEED:Array=[30,20,10,5];11.12.privateconstVK_H:int=72;//h13.privateconstVK_J:int=74;//j14.privateconstVK_K:int=7
5、5;//k15.privateconstVK_L:int=76;//l16.privateconstVK_SPC:int=32;//space17.18.privatevarfield:Array=[];19.privatevarpiece:Array;20.privatevarnext:Array;21.privatevartext:TextField=newTextField();22.privatevarkeytable:Array=[];23.privatevarcount:int=0;24.privatevarstep:in
6、t=0;25.privatevarpx:int;26.privatevarpy:int;27.28.privatevarlight:PointLight3D;1.2.publicfunctionTetris(){3.Wonderfl.capture_delay(25);4.5.light=newPointLight3D(false);6.light.x=500;7.light.y=-750;8.light.z=1500;9.10.text.x=300;11.text.textColor=0xFFFFFF;12.text.text="N
7、ext:";13.addChild(text);14.vart:TextField=newTextField();15.t.textColor=0xFFFFFF;16.t.text="Keys:H,J,K,L,SPACE";17.t.scaleX=t.scaleY=1.25;18.t.width=250;19.20.addChild(t);21.field=newArray(H).map(function():*{22.returnnewArray(W).map(function():*{23.return0;24.})25.});2
8、6.keytable[VK_H]=function():void{px-=space(px-1,py,piece)};1.keytable[VK_J]=function():void{rotate(true)};2.ke