c#經典俄羅斯方塊 vs2012開發

 

把網上兩個開源的俄羅斯方塊,整合到一塊兒了,開發環境vs2012+.net 4.0,有問題、建議能夠加羣溝通哦html

 

復古的 c#寫的一個俄羅斯方塊小遊戲,友好的人機交互,具體功能以下:
1.遊戲分七個關卡,通關後還有通關加分。
2.有卡通背景圖。
3.有背景音樂和音效。
4.有得分排行榜。
5.能手動更換遊戲背景圖和背景音樂
6.能自定義遊戲控制鍵。

貼出一段核心代碼,如何消行的,本個俄羅斯方塊的核心就是 對於 &|>>^4種位運算符的運用,也是我整合這兩個俄羅斯方塊 的亮點,歡迎你們提出改進意見
 1    /// <summary>
 2         /// 查找已被填滿的行
 3         /// </summary>
 4         /// <returns></returns>
 5         public List<int>  FindFullLines()
 6         {
 7             
 8             //清空原暫存表
 9             fullLines.Clear();
10             keepLines.Clear();
11             List<Position> reDrawPosList = new List<Position>();
12             //從最底行開始檢查是否有消除行
13             for (int y = this.YBlocks - 1; y >= 0 && arrBitBlock[y] != bitEmpty; )
14             {
15                 if (arrBitBlock[y] == bitFull)
16                 {
17                     for (int x = 0; x < xBlocks; x++) //消除該行的block
18                         ArrayBlock[x, y] = null;
19                     SquareBlock[] arr = null;
20                     //將該行之上的block下移,若是到頂則不執行
21                     for (int i = y; i - 1 >= 0; i--)
22                     {
23                        //記錄最高的 圖形
24                         arr = new SquareBlock[10];
25                         for (int x = 0; x < xBlocks; x++)
26                         {
27                           
28                            if ((arrBitBlock[i - 1] & (1 << x)) != 0) //若是上方有block
29                            
30                             {
31                                 this.ArrayBlock[x, i] = this.ArrayBlock[x, i - 1] == null ? null : this.ArrayBlock[x, i - 1].Clone() as SquareBlock;                              
32 
33                                 ArrayBlock[x, i - 1] = null;
34                                 reDrawPosList.Add(new Position(x, i));
35 
36                                 //ArrayBlock[x, i] = ArrayBlock[x, i - 1].Clone() as SquareBlock;
37                             }
38                         }
39                         arrBitBlock[i] = arrBitBlock[i - 1];//轉移監控位
40                     }
41 
42                     destroyLines++;
43                     fullLines.Add(y - fullLines.Count());
44 
45                    
46                 }
47                 else
48                 {
49                     keepLines.Add(y - fullLines.Count());
50                     y--;//當消除一行後指針不下移,當沒有消除的時候指針才下移
51                    
52                 }
53                 MinY = y - fullLines.Count();
54             }
55             return fullLines;
56         }

 

 

 

參考:  http://download.csdn.net/detail/free722/1883329c#

 

參考:http://www.cnblogs.com/tuyile006/archive/2007/05/16/748256.htmlthis

相關文章
相關標籤/搜索