zoukankan      html  css  js  c++  java
  • c#经典俄罗斯方块 vs2012开发

    把网上两个开源的俄罗斯方块,整合到一起了,开发环境vs2012+.net 4.0,有问题、建议可以加群沟通哦

    复古的 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/1883329

    参考:http://www.cnblogs.com/tuyile006/archive/2007/05/16/748256.html

  • 相关阅读:
    移动硬盘文件被恶意隐藏
    asp.net identity UserSecurityStamp 的作用
    Head First Python学习笔记1
    WPF 确认动态加载数据完成
    rust by example 2
    Rust by Example1
    奇葩!把类型转成object
    Lambda高手之路第一部分
    理解Lambda表达式
    贪心算法-找零钱(C#实现)
  • 原文地址:https://www.cnblogs.com/Impulse/p/4923102.html
Copyright © 2011-2022 走看看