黑马程序员 wp7 俄罗斯方块 源代码

2 篇文章 0 订阅
1 篇文章 0 订阅

---------------------- Windows Phone 7手机开发  Net培训、期待与您交流! ----------------------

一.创建了各种各样的方块样式的源代码      

  /// <summary>
        /// 创建了piece (砖块)各种各样的款式
        ///   这个的样式有各种各样的类型 如'田'字型,'N'类型,'T'类型等等
        ///   而且我们使他起始位置是(0,3)坐标的位置
        /// </summary>
        private void CreatePiece()
        {
            for (int x = 0; x < _columns; x++)
            {

                if (Container[0,x].Color!=null)
                {
                    OnGameOver(null);
                    break;
                }
            }

            Random random = new Random();
            _currentPiece = _nextPiece == null ? _pieces[random.Next(0, 7)] : _nextPiece;
            _nextPiece = _pieces[random.Next(0, 7)];

            _positionX = 3;
            _positionY = 0;
            SetNextContainerUI();
        }


一个是消去 方块的方法

public void Clear() { for (int x = 0; x < _columns; x++) { for (int y = 0; y < _rows; y++) { Container[y, x].Color = null; }

一个判断砖块是否是出界的方法

private bool IsBoundary(int[,] matrix, int offsetX, int offsetY) { RemovePiece(); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (matrix[i, j] == 1) { if (j + _positionX + offsetX > _columns - 1 || i + _positionY + offsetY > _rows - 1 || j + _positionX + offsetX < 0 || Container[i + _positionY + offsetY, j + _positionX + offsetX].Color != null) { AddPiece(0, 0); return true; } } } } AddPiece(0, 0); return false; }

---------------------- Windows Phone 7手机开发、.Net培训、期待与您交流! ----------------------

详细请查看:http://net.itheima.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值