C#俄罗斯方块程序设计与简单实现

上传者: coderjyf | 上传时间: 2020-01-03 11:18:36 | 文件大小: 12.05MB | 文件类型: rar
C#俄罗斯方块程序设计与简单实现 效果演示:https://www.cnblogs.com/JiYF/p/9632821.html可以到这里查看效果,当然有部分bug还需要解决 相信90后或者80后都玩过这款小游戏,一直想干一票,琢磨一下,但又不太懂,于是网上搜集修改就有了以下效果!bug较多,多多包涵! 1.效果展示 2.实现方法 参考https://blog.csdn.net/qian_f/article/details/19758671 感谢博主分享,我在这里也没修改啥,有时间修复几个bug 2.1对象分析 把每个砖块当成一个对象。每个砖块都有共同的行为,就是可以左移、 右移、下移和变形。既然这是他们共同的行为(方法),那么可以定义一个虚基类Brick,然后在该基类中声明这些行为。当然,砖块在做这些行为前需要知道能不能进行这些行为,比如说到了左边界就不能左移;到了下边界就不能下移;周围空间不够大,就不能变形等等。因此该基类还需要声明一些虚函数:CanTransform() CanLeftMove() CanRightMove() CanDropMove()等。 2.2继承实现 继承定义的基类,每种砖块根据自身的形状具体实现相应函数。据说在标准的俄罗斯方块中,一共有七种形状。本练习项目中定义的方块和变形方式(绕着中心点顺时针旋转,途中颜色较深的点就是中心点)如下: 根据上图就可以知道,表示砖块最好的方法就是用二维数组了。对于砖块而言,这个二维数组就是它的变形范围,数组中的数字为0,代表砖块在该区域中无显示,为1代表有显示。在实现CanTransform() CanLeftMove() CanRightMove() CanDropMove()这四个函数时,要尤其小心,这边是最容易出错的地方。 2.3画布处理 完成砖块下面就要进行画布的处理了。可以想象一下,把画布分成多个方格,也就相当于二维数组了,然后把砖块所对应的二维数组按指定的位置放到代表画布的二维数组中。在显示的时候就可以根据值为1的方格来获取位置并进行绘图了。所以,该项目中定义了一个名为Canvas的类,核心功能是用于获取这个二维数组的值,其中包含根据砖块设置数组的值、行满(一行里所有的值都为1)之后消除、超出高度后返回失败等。 2.4绘图 真正的绘图操作。根据二维数组的值绘制显示,并响应方向键操作。 3.代码实现

文件下载

资源详情

[{"title":"( 83 个子文件 12.05MB ) C#俄罗斯方块程序设计与简单实现","children":[{"title":"05BenNHTetris","children":[{"title":".svn","children":[{"title":"tmp","children":null,"spread":false},{"title":"wc.db <span style='color:#111;'> 132.00KB </span>","children":null,"spread":false},{"title":"pristine","children":[{"title":"66","children":[{"title":"6607e26735d9bb74994f153cd315327ea053f573.svn-base <span style='color:#111;'> 2.01KB </span>","children":null,"spread":false}],"spread":true},{"title":"02","children":[{"title":"02e85a64cba779e856a6a378a06b509ded44c966.svn-base <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false}],"spread":true},{"title":"b3","children":[{"title":"b3deee6571969175a95ff74054d0cb6205e88763.svn-base <span style='color:#111;'> 3.50KB </span>","children":null,"spread":false}],"spread":true},{"title":"87","children":[{"title":"879225c7e50303da3b30a0ff2b8ef12f25e12453.svn-base <span style='color:#111;'> 4.13KB </span>","children":null,"spread":false}],"spread":true},{"title":"90","children":[{"title":"90a440037834c74a6cd80af76201a3c4309c34e1.svn-base <span style='color:#111;'> 1.63KB </span>","children":null,"spread":false}],"spread":true},{"title":"2f","children":[{"title":"2fe30ae0a086eeeb84f71326f7cf9567578e72c2.svn-base <span style='color:#111;'> 12.06KB </span>","children":null,"spread":false}],"spread":true},{"title":"5e","children":[{"title":"5e1d04de66ffcc5dfd813530ab6992e6daaae417.svn-base <span style='color:#111;'> 249B </span>","children":null,"spread":false}],"spread":true},{"title":"f7","children":[{"title":"f76d36caece5f335c225bd3598b04292059f6cbc.svn-base <span style='color:#111;'> 21.40KB </span>","children":null,"spread":false}],"spread":true},{"title":"71","children":[{"title":"71ff4385ae80f895aa992ae2cada17db4c6c5df0.svn-base <span style='color:#111;'> 18.49KB </span>","children":null,"spread":false}],"spread":true},{"title":"a5","children":[{"title":"a54911d99af1525f608f2045952acbac3c06c8ee.svn-base <span style='color:#111;'> 1.33KB </span>","children":null,"spread":false}],"spread":false},{"title":"36","children":[{"title":"36a1325bd8f934d1fbe72c15d3d94e204c14ee93.svn-base <span style='color:#111;'> 1002B </span>","children":null,"spread":false}],"spread":false},{"title":"53","children":[{"title":"5351c0828f1c299d0074824ece42efe241936b31.svn-base <span style='color:#111;'> 2.60KB </span>","children":null,"spread":false}],"spread":false},{"title":"0e","children":[{"title":"0e42c87c47c44e63e3e11e1706ad6e94c545b1ad.svn-base <span style='color:#111;'> 2.03KB </span>","children":null,"spread":false}],"spread":false},{"title":"33","children":[{"title":"3323eed01c6c487289e0895005be3e47b4ed22b3.svn-base <span style='color:#111;'> 5.93KB </span>","children":null,"spread":false},{"title":"336a624c12d5496abc4b0714ea54d240598ef1c2.svn-base <span style='color:#111;'> 14.41KB </span>","children":null,"spread":false}],"spread":false},{"title":"52","children":[{"title":"52899819fd2ae36ff0622cac845c0d209da4a92b.svn-base <span style='color:#111;'> 1.60KB </span>","children":null,"spread":false}],"spread":false},{"title":"31","children":[{"title":"31fb76e5d9babe97a11fea041081f96ce426107a.svn-base <span style='color:#111;'> 5.68KB </span>","children":null,"spread":false}],"spread":false},{"title":"dd","children":[{"title":"dd5d1458d362d9fbf3f7a0a15d4e818556cbcf36.svn-base <span style='color:#111;'> 35.00KB </span>","children":null,"spread":false}],"spread":false},{"title":"63","children":[{"title":"63bcbc96958904c0d420d9345c937a1151a86474.svn-base <span style='color:#111;'> 13.99KB </span>","children":null,"spread":false}],"spread":false},{"title":"c9","children":[{"title":"c99c0a8818c75c63a19b98e0a0c895d5b391b601.svn-base <span style='color:#111;'> 12.06KB </span>","children":null,"spread":false},{"title":"c9f000d08b76a20078a8c0cdcdf4582aab19cf23.svn-base <span style='color:#111;'> 5.93MB </span>","children":null,"spread":false}],"spread":false},{"title":"4a","children":[{"title":"4a43b9681c5ba52e70965f2bd85bf512a153f7f2.svn-base <span style='color:#111;'> 1.61KB </span>","children":null,"spread":false}],"spread":false},{"title":"8c","children":[{"title":"8cc49c5e215283c57e3040e100c66e5958c331dd.svn-base <span style='color:#111;'> 17.92KB </span>","children":null,"spread":false}],"spread":false},{"title":"47","children":[{"title":"47c899ebda9aeb147b63dd73a54a0985310e54a4.svn-base <span style='color:#111;'> 2.50KB </span>","children":null,"spread":false},{"title":"47b15748ecc8e952c5935170090db7c269ce4b4f.svn-base <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":false},{"title":"b9","children":[{"title":"b93e4ea5ba7d3013821ada3b476e35021b8cffc6.svn-base <span style='color:#111;'> 494B </span>","children":null,"spread":false}],"spread":false},{"title":"e2","children":[{"title":"e2f34b58f1533825708551b938328f5168111a21.svn-base <span style='color:#111;'> 14.41KB </span>","children":null,"spread":false}],"spread":false},{"title":"ef","children":[{"title":"ef07158a33feddea879fa82647dac86cbc41c043.svn-base <span style='color:#111;'> 12.31KB </span>","children":null,"spread":false}],"spread":false},{"title":"b4","children":[{"title":"b499c73375c0b5f54607dd4e71f20dbfb0e529e1.svn-base <span style='color:#111;'> 11.76KB </span>","children":null,"spread":false}],"spread":false},{"title":"e4","children":[{"title":"e45cc231967690492ae16efdcce1dc3643f8333a.svn-base <span style='color:#111;'> 1.58KB </span>","children":null,"spread":false}],"spread":false},{"title":"ad","children":[{"title":"adf81728a6c9ada869a110f07d3642d0dfd6700a.svn-base <span style='color:#111;'> 2.81KB </span>","children":null,"spread":false}],"spread":false},{"title":"c7","children":[{"title":"c706037b17b9d02fbdb637d970f16f96aa175f4e.svn-base <span style='color:#111;'> 350B </span>","children":null,"spread":false}],"spread":false},{"title":"cb","children":[{"title":"cb61fd5448597e7b444afe25fa99a566d84fa27b.svn-base <span style='color:#111;'> 10.59KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"entries <span style='color:#111;'> 3B </span>","children":null,"spread":false},{"title":"wc.db-journal <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"format <span style='color:#111;'> 3B </span>","children":null,"spread":false}],"spread":true},{"title":"Images","children":[{"title":"clipboard.png <span style='color:#111;'> 17.92KB </span>","children":null,"spread":false},{"title":"俄罗斯方块带水印.gif <span style='color:#111;'> 5.93MB </span>","children":null,"spread":false},{"title":"clipboard2.png <span style='color:#111;'> 18.49KB </span>","children":null,"spread":false},{"title":"clipboard3.png <span style='color:#111;'> 21.40KB </span>","children":null,"spread":false}],"spread":true},{"title":"README.md <span style='color:#111;'> 2.50KB </span>","children":null,"spread":false},{"title":".gitignore <span style='color:#111;'> 350B </span>","children":null,"spread":false},{"title":"BenNHTetris","children":[{"title":"Library","children":[{"title":"BenNHControl.dll <span style='color:#111;'> 35.00KB </span>","children":null,"spread":false}],"spread":true},{"title":"images","children":[{"title":"Max.png <span style='color:#111;'> 1.60KB </span>","children":null,"spread":false},{"title":"Close.png <span style='color:#111;'> 2.01KB </span>","children":null,"spread":false},{"title":"MaxNormal.png <span style='color:#111;'> 1.63KB </span>","children":null,"spread":false},{"title":"VSLogo.png <span style='color:#111;'> 2.03KB </span>","children":null,"spread":false},{"title":"Min.png <span style='color:#111;'> 1.58KB </span>","children":null,"spread":false}],"spread":true},{"title":"BenNHTetris.sln <span style='color:#111;'> 1002B </span>","children":null,"spread":false},{"title":"BenNHTetris","children":[{"title":"Block7.cs <span style='color:#111;'> 14.41KB </span>","children":null,"spread":false},{"title":"Block6.cs <span style='color:#111;'> 14.41KB </span>","children":null,"spread":false},{"title":"Block.cs <span style='color:#111;'> 3.50KB </span>","children":null,"spread":false},{"title":"Block1.cs <span style='color:#111;'> 2.60KB </span>","children":null,"spread":false},{"title":"BenNHTetris.csproj <span style='color:#111;'> 4.13KB </span>","children":null,"spread":false},{"title":"Program.cs <span style='color:#111;'> 494B </span>","children":null,"spread":false},{"title":"Block5.cs <span style='color:#111;'> 12.06KB </span>","children":null,"spread":false},{"title":"Block4.cs <span style='color:#111;'> 12.06KB </span>","children":null,"spread":false},{"title":"Blocks.cs <span style='color:#111;'> 1.61KB </span>","children":null,"spread":false},{"title":"FrmMain.cs <span style='color:#111;'> 5.93KB </span>","children":null,"spread":false},{"title":"Block2.cs <span style='color:#111;'> 13.99KB </span>","children":null,"spread":false},{"title":"Properties","children":[{"title":"Settings.settings <span style='color:#111;'> 249B </span>","children":null,"spread":false},{"title":"Resources.Designer.cs <span style='color:#111;'> 2.81KB </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.33KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":false},{"title":"Canvas.cs <span style='color:#111;'> 10.59KB </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"BenNHTetris.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"BenNHTetris.csprojResolveAssemblyReference.cache <span style='color:#111;'> 7.26KB </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"BenNHTetris.pdb <span style='color:#111;'> 95.50KB </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 6.75KB </span>","children":null,"spread":false},{"title":"BenNHTetris.csproj.GenerateResource.Cache <span style='color:#111;'> 979B </span>","children":null,"spread":false},{"title":"BenNHTetris.exe <span style='color:#111;'> 44.00KB </span>","children":null,"spread":false},{"title":"BenNHTetris.FrmMain.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"BenNHTetris.csproj.FileListAbsolute.txt <span style='color:#111;'> 821B </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"FrmMain.resx <span style='color:#111;'> 5.68KB </span>","children":null,"spread":false},{"title":"bin","children":[{"title":"Debug","children":[{"title":"BenNHTetris.vshost.exe <span style='color:#111;'> 23.65KB </span>","children":null,"spread":false},{"title":"BenNHTetris.pdb <span style='color:#111;'> 95.50KB </span>","children":null,"spread":false},{"title":"BenNHTetris.vshost.exe.manifest <span style='color:#111;'> 490B </span>","children":null,"spread":false},{"title":"BenNHTetris.exe <span style='color:#111;'> 44.00KB </span>","children":null,"spread":false},{"title":"BenNHControl.dll <span style='color:#111;'> 35.00KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"FrmMain.Designer.cs <span style='color:#111;'> 11.76KB </span>","children":null,"spread":false},{"title":"Block3.cs <span style='color:#111;'> 12.31KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明