3、m>#include#includeusingnamespacestd;#defineLEFT'a'#defineRIGHT'd'#defineUP'w'#defineDOWN's'#defineSTART0//定義圖形的圍#defineEND19#defineSIZE25/**初始化七個(gè)二維數(shù)組,即七個(gè)塊剛開始產(chǎn)生時(shí)出現(xiàn)的位置*這里需要考慮的情況是:剛開始產(chǎn)生時(shí)有的方塊還只露出來一部分,*如果這個(gè)時(shí)候按了UP鍵進(jìn)行變換應(yīng)該怎么處理*本程序最初設(shè)計(jì)并不考慮這個(gè)問題,一開始即畫出方塊的各個(gè)部分,以后再考慮完善的事情word范文.*另外,記錄坐
4、標(biāo)的順序?yàn)閺淖笾劣?,從上至?/GLfloatb[][5][3]={{{0.0f,0.9f},{0.0f,0.8f},{0.0f,0.7f},{0.0f,0.6f}},//1、記錄長條四個(gè)坐標(biāo){{-0.1f,0.9f},{0.0f,0.9f},{-0.1f,0.8f},{0.0f,0.8f}},//2、記錄正方形{{-0.1f,0.9f},{-0.2f,0.8f},{-0.1f,0.8f},{0.0f,0.8f}},//3、T字形{{-0.1f,0.9f},{0.0f,0.9f},{0.0f,0.8f},{0.1f,0.8f}},//4、記錄Z字形{{-0.1f,0.9f},{
5、0.0f,0.9f},{-0.2f,0.8f},{-0.1f,0.8f}},//5、記錄倒Z字形{{-0.1f,0.9f},{-0.1f,0.8f},{-0.1f,0.7f},{0.0f,0.7f}},//6、記錄L字形{{0.0f,0.9f},{0.0f,0.8f},{-0.1f,0.7f},{0.0f,0.7f}},//7、記錄倒L字形};GLfloatcurLoc[5][3];GLintcurrentBlock=2;//記錄當(dāng)前正在下落的是第幾種方塊,順序如上面所示GLintturn[7]={0};//應(yīng)該變換成第幾種形態(tài)了GLfloatxd=0.0f,yd=0.0f;/
6、*這里定義的over是用來判斷方塊是否到達(dá)了不能再往下降的地方,到了則置其為true,否則就修改為false。其中有這樣幾種情況需要修改over:1、重新生成了一個(gè)方塊,修改over=false2、方塊到大底部,修改over=true*/boolover=false;//記錄游戲是否結(jié)束boolend=false;intscore=0;word范文.//設(shè)置一個(gè)鎖,在下降操作時(shí)不允許變換,在變換時(shí)不允許下降操作,否則將會(huì)產(chǎn)生資源競爭//intlock=1;/*定義一個(gè)20*20的矩陣來記錄當(dāng)前整個(gè)畫面中各個(gè)小格子的情況,可用來消除滿格行矩陣的存儲(chǔ)順序?yàn)閺淖蟮接遥瑥南碌缴?,包含?/p>
7、標(biāo)0BLOCK[i][j]中i對(duì)應(yīng)的是縱坐標(biāo),j對(duì)應(yīng)的是橫坐標(biāo)(這個(gè)有點(diǎn)痛苦),但是在消去滿格的時(shí)候還是不變,只是在用b數(shù)組給其賦值時(shí)需要反過來*/GLintBLOCK[SIZE][SIZE];voiddown(intid);voidInitBLOCK();voidChange();voidCheckDelete();intCheckConflict(intlef_rig=0);voidCreateBlocks();voidmyDisplay1();voidkey(unsignedchark