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

相信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.代码实现

Block基类

  1. public abstract class Block
  2. {
  3. protected int _curChangeTimes; //变化次数
  4. public int _needRows; //行数
  5. public int _needColumns; //列数
  6. public int[,] _range; //变化范围
  7. public Point _center; //中心点 相对于必要区域
  8. public Point _Pos; //中心点位置,相对于画布
  9.  
  10. /// <summary>
  11. /// 能否变形 ,能变形的条件为在方块的变形范围内不能有其它的方块
  12. /// </summary>
  13. /// <param name="arr"></param>
  14. /// <param name="rows"></param>
  15. /// <param name="cloumns"></param>
  16. /// <returns></returns>
  17. public abstract bool CanChange(int[,] arr ,int rows,int cloumns);
  18.  
  19. /// <summary>
  20. /// 变形
  21. /// </summary>
  22. public abstract void Change();
  23.  
  24. /// <summary>
  25. /// 能否左移动
  26. /// </summary>
  27. /// <param name="arr"></param>
  28. /// <param name="rows"></param>
  29. /// <param name="columns"></param>
  30. /// <returns></returns>
  31. public abstract bool CanLeftMove(int[,] arr,int rows,int columns);
  32.  
  33. /// <summary>
  34. /// 左移
  35. /// </summary>
  36. public void LeftMove()
  37. {
  38. _Pos.Y -= ;
  39. }
  40.  
  41. /// <summary>
  42. /// 能否右移
  43. /// </summary>
  44. /// <param name="arr"></param>
  45. /// <param name="rows"></param>
  46. /// <param name="columns"></param>
  47. /// <returns></returns>
  48. public abstract bool CanRightMove(int[,] arr, int rows, int columns);
  49.  
  50. /// <summary>
  51. /// 右侧移动
  52. /// </summary>
  53. public void RightMove()
  54. {
  55. _Pos.Y += ;
  56. }
  57.  
  58. /// <summary>
  59. /// 能否下移
  60. /// </summary>
  61. /// <param name="arr"></param>
  62. /// <param name="rows"></param>
  63. /// <param name="columns"></param>
  64. /// <returns></returns>
  65. public abstract bool CanDownMove(int[,] arr, int rows, int columns);
  66.  
  67. /// <summary>
  68. /// 下侧移动
  69. /// </summary>
  70. public void DownMove()
  71. {
  72. _Pos.X += ;
  73. }
  74.  
  75. /// <summary>
  76. /// 随机生成一个可以通过变形得到的形状
  77. /// </summary>
  78. public void RandomShape()
  79. {
  80. Random random = new Random();
  81. this._curChangeTimes = random.Next();
  82. this.Change();
  83. }
  84.  
  85. /// <summary>
  86. /// 设置中心点相对于画布的位置
  87. /// </summary>
  88. /// <param name="x">横向位置</param>
  89. /// <param name="y">纵向位置</param>
  90. public void SetCenterPos(int x, int y)
  91. {
  92. this._Pos = new Point(x, y);
  93. }
  94.  
  95. /// <summary>
  96. /// 获取方块出现时中心点的Y轴坐标
  97. /// </summary>
  98. /// <returns></returns>
  99. public abstract int Appear();
  100. }

Block1类

  1. class Block1:Block
  2. {
  3. public Block1()
  4. {
  5. this._curChangeTimes = ;
  6. this._needRows = ;
  7. this._needColumns = ;
  8. _range = new int[, ]{
  9. {,},
  10. {,}
  11. };
  12.  
  13. this._center = new Point(,);
  14. this._Pos = new Point();
  15. }
  16.  
  17. public override bool CanChange(int[,] arr, int rows, int cloumns)
  18. {
  19. return false;
  20. }
  21.  
  22. public override void Change()
  23. {
  24. return;
  25. }
  26.  
  27. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  28. {
  29. if (_Pos.X < )
  30. {
  31. if (_Pos.Y == || arr[_Pos.X + , _Pos.Y - ] == )
  32. {
  33. return false;
  34. }
  35. else
  36. {
  37. return true;
  38. }
  39. }
  40. if (_Pos.Y == || arr[_Pos.X, _Pos.Y - ] == || arr[_Pos.X + , _Pos.Y - ] == )
  41. return false;
  42. else
  43. return true;
  44. }
  45.  
  46. public override bool CanRightMove(int[,] arr, int rows, int columns)
  47. {
  48. if (_Pos.X < )
  49. {
  50. if (_Pos.Y == columns - || arr[_Pos.X + , _Pos.Y + ] == )
  51. {
  52. return false;
  53. }
  54. else
  55. {
  56. return true;
  57. }
  58. }
  59. if (_Pos.Y == columns - || arr[_Pos.X, _Pos.Y + ] == || arr[_Pos.X + , _Pos.Y + ] == )
  60. return false;
  61. else
  62. return true;
  63. }
  64.  
  65. public override bool CanDownMove(int[,] arr, int rows, int columns)
  66. {
  67. if (_Pos.X < rows - && arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  68. return true;
  69. return false;
  70. }
  71.  
  72. public override int Appear()
  73. {
  74. return -;
  75. }
  76. }

Block2类

  1. class Block2:Block
  2. {
  3. public Block2()
  4. {
  5. this._curChangeTimes = ;
  6. this._needRows = ;
  7. this._needColumns = ;
  8. this._range = new int[, ]{{,,,,},
  9. {,,,,},
  10. {,,,,},
  11. {,,,,},
  12. {,,,,}};
  13. this._center = new Point(, );
  14. }
  15. public override bool CanChange(int[,] arr, int rows, int cloumns)
  16. {
  17. bool result = false;
  18. if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
  19. {
  20. switch (_curChangeTimes)
  21. {
  22. case :
  23. arr[_Pos.X, _Pos.Y - ] = ;
  24. arr[_Pos.X, _Pos.Y] = ;
  25. arr[_Pos.X, _Pos.Y + ] = ;
  26. arr[_Pos.X, _Pos.Y + ] = ;
  27. break;
  28. case :
  29. arr[_Pos.X - , _Pos.Y] = ;
  30. arr[_Pos.X, _Pos.Y] = ;
  31. arr[_Pos.X + , _Pos.Y] = ;
  32. arr[_Pos.X + , _Pos.Y] = ;
  33. break;
  34. case :
  35. arr[_Pos.X, _Pos.Y - ] = ;
  36. arr[_Pos.X, _Pos.Y - ] = ;
  37. arr[_Pos.X, _Pos.Y] = ;
  38. arr[_Pos.X, _Pos.Y + ] = ;
  39. break;
  40. case :
  41. arr[_Pos.X - , _Pos.Y] = ;
  42. arr[_Pos.X - , _Pos.Y] = ;
  43. arr[_Pos.X, _Pos.Y] = ;
  44. arr[_Pos.X + , _Pos.Y] = ;
  45. break;
  46. default:
  47. break;
  48. }
  49. bool temp = true;
  50. for (int i = -; i < ; i++)
  51. {
  52. for (int j = -; j < ; j++)
  53. {
  54. if (arr[_Pos.X + i, _Pos.Y + j] == )
  55. {
  56. temp = false;
  57. goto break2;
  58. }
  59. }
  60. }
  61. break2:
  62. result = temp;
  63. switch (_curChangeTimes)
  64. {
  65. case :
  66. arr[_Pos.X, _Pos.Y - ] = ;
  67. arr[_Pos.X, _Pos.Y] = ;
  68. arr[_Pos.X, _Pos.Y + ] = ;
  69. arr[_Pos.X, _Pos.Y + ] = ;
  70. break;
  71. case :
  72. arr[_Pos.X - , _Pos.Y] = ;
  73. arr[_Pos.X, _Pos.Y] = ;
  74. arr[_Pos.X + , _Pos.Y] = ;
  75. arr[_Pos.X + , _Pos.Y] = ;
  76. break;
  77. case :
  78. arr[_Pos.X, _Pos.Y - ] = ;
  79. arr[_Pos.X, _Pos.Y - ] = ;
  80. arr[_Pos.X, _Pos.Y] = ;
  81. arr[_Pos.X, _Pos.Y + ] = ;
  82. break;
  83. case :
  84. arr[_Pos.X - , _Pos.Y] = ;
  85. arr[_Pos.X - , _Pos.Y] = ;
  86. arr[_Pos.X, _Pos.Y] = ;
  87. arr[_Pos.X + , _Pos.Y] = ;
  88. break;
  89. default:
  90. break;
  91. }
  92. }
  93. return result;
  94. }
  95.  
  96. public override void Change()
  97. {
  98. switch (_curChangeTimes)
  99. {
  100. case :
  101. _range = new int[, ]{{,,,,},
  102. {,,,,},
  103. {,,,,},
  104. {,,,,},
  105. {,,,,}};
  106. _curChangeTimes = ;
  107. break;
  108. case :
  109. _range = new int[, ]{{,,,,},
  110. {,,,,},
  111. {,,,,},
  112. {,,,,},
  113. {,,,,}};
  114. _curChangeTimes = ;
  115. break;
  116. case :
  117. _range = new int[, ]{{,,,,},
  118. {,,,,},
  119. {,,,,},
  120. {,,,,},
  121. {,,,,}};
  122. _curChangeTimes = ;
  123. break;
  124. case :
  125. _range = new int[, ]{{,,,,},
  126. {,,,,},
  127. {,,,,},
  128. {,,,,},
  129. {,,,,}};
  130. _curChangeTimes = ;
  131. break;
  132. default:
  133. break;
  134. }
  135. }
  136.  
  137. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  138. {
  139. bool result = false;
  140. switch (_curChangeTimes)
  141. {
  142. case :
  143. if (_Pos.Y > )
  144. {
  145. if (arr[_Pos.X, _Pos.Y - ] == )
  146. {
  147. result = true;
  148. }
  149. else
  150. {
  151. result = false;
  152. }
  153. }
  154. break;
  155. case :
  156. if (_Pos.Y > )
  157. {
  158. bool temp = true;
  159. for (int i = -; i < ; i++)
  160. {
  161. if (_Pos.X + i < )
  162. {
  163. continue;
  164. }
  165. else
  166. {
  167. if (arr[_Pos.X + i, _Pos.Y - ] == )
  168. {
  169. temp = false;
  170. break;
  171. }
  172. }
  173. }
  174. result = temp;
  175. }
  176. break;
  177. case :
  178. if (_Pos.Y > )
  179. {
  180. if (arr[_Pos.X, _Pos.Y - ] == )
  181. {
  182. result = true;
  183. }
  184. else
  185. {
  186. result = false;
  187. }
  188. }
  189. break;
  190. case :
  191. if (_Pos.Y > )
  192. {
  193. bool temp = true;
  194. for (int i = -; i < ; i++)
  195. {
  196. if (_Pos.X + i < )
  197. {
  198. continue;
  199. }
  200. else
  201. {
  202. if (arr[_Pos.X + i, _Pos.Y - ] == )
  203. {
  204. temp = false;
  205. break;
  206. }
  207. }
  208. }
  209. result = temp;
  210. }
  211. break;
  212. default:
  213. break;
  214. }
  215. return result;
  216. }
  217.  
  218. public override bool CanRightMove(int[,] arr, int rows, int columns)
  219. {
  220. bool result = false;
  221. switch (_curChangeTimes)
  222. {
  223. case :
  224. if (_Pos.Y < columns - )
  225. {
  226. if (arr[_Pos.X, _Pos.Y + ] == )
  227. {
  228. result = true;
  229. }
  230. else
  231. {
  232. result = false;
  233. }
  234. }
  235. break;
  236. case :
  237. if (_Pos.Y < columns - )
  238. {
  239. bool temp = true;
  240. for (int i = -; i < ; i++)
  241. {
  242. if (_Pos.X + i < )
  243. {
  244. continue;
  245. }
  246. else
  247. {
  248. if (arr[_Pos.X + i, _Pos.Y + ] == )
  249. {
  250. temp = false;
  251. break;
  252. }
  253. }
  254. }
  255. result = temp;
  256. }
  257. break;
  258. case :
  259. if (_Pos.Y < columns - )
  260. {
  261. if (arr[_Pos.X, _Pos.Y + ] == )
  262. {
  263. result = true;
  264. }
  265. else
  266. {
  267. result = false;
  268. }
  269. }
  270. break;
  271. case :
  272. if (_Pos.Y < columns - )
  273. {
  274. bool temp = true;
  275. for (int i = -; i < ; i++)
  276. {
  277. if (_Pos.X + i < )
  278. {
  279. continue;
  280. }
  281. else
  282. {
  283. if (arr[_Pos.X + i, _Pos.Y + ] == )
  284. {
  285. temp = false;
  286. break;
  287. }
  288. }
  289. }
  290. result = temp;
  291. }
  292. break;
  293. default:
  294. break;
  295. }
  296. return result;
  297. }
  298.  
  299. public override bool CanDownMove(int[,] arr, int rows, int columns)
  300. {
  301. bool result = false;
  302. switch (_curChangeTimes)
  303. {
  304. case :
  305. if (_Pos.X != rows - )
  306. {
  307. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y - ] == )
  308. {
  309. result = true;
  310. }
  311. else
  312. {
  313. result = false;
  314. }
  315. }
  316. break;
  317. case :
  318. if (_Pos.X != rows - )
  319. {
  320. if (arr[_Pos.X + , _Pos.Y] == )
  321. {
  322. result = true;
  323. }
  324. else
  325. {
  326. result = false;
  327. }
  328. }
  329. break;
  330. case :
  331. if (_Pos.X != rows - )
  332. {
  333. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  334. {
  335. result = true;
  336. }
  337. else
  338. {
  339. result = false;
  340. }
  341. }
  342. break;
  343. case :
  344. if (_Pos.X != rows - )
  345. {
  346. if (arr[_Pos.X + , _Pos.Y] == )
  347. {
  348. result = true;
  349. }
  350. else
  351. {
  352. result = false;
  353. }
  354. }
  355. break;
  356. default:
  357. break;
  358. }
  359. return result;
  360. }
  361.  
  362. public override int Appear()
  363. {
  364. int result = ;
  365. switch (_curChangeTimes)
  366. {
  367. case :
  368. result = ;
  369. break;
  370. case :
  371. result = -;
  372. break;
  373. case :
  374. result = ;
  375. break;
  376. case :
  377. result = -;
  378. break;
  379. default:
  380. break;
  381. }
  382. return result;
  383. }
  384. }

Block3

  1. ///////////////////////////////////////////////////////////
  2. // Class : Block3.cs
  3. // CLRVersion : 4.0.30319.42000
  4. // NameSpace : BenNHTetris
  5. // Created on : 2018/5/31 11:41:56
  6. // Original author : JIYONGFEI
  7. // JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
  8. ///////////////////////////////////////////////////////////
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14.  
  15. namespace BenNHTetris
  16. {
  17. class Block3:Block
  18. {
  19. public Block3()
  20. {
  21. _curChangeTimes = ;
  22. _needRows = ;
  23. _needColumns = ;
  24. _range = new int[, ]{{,,},
  25. {,,},
  26. {,,}};
  27. _center = new Point(, );
  28. }
  29. public override bool CanChange(int[,] arr, int rows, int cloumns)
  30. {
  31. bool result = true;
  32. if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
  33. {
  34. for (int i = -; i < ; i++)
  35. {
  36. for (int j = -; j < ; j++)
  37. {
  38. switch (_curChangeTimes)
  39. {
  40. case :
  41. if (i == - && j == || i == && j == - || i == && j == || i == && j == )
  42. {
  43. continue;
  44. }
  45. break;
  46. case :
  47. if (i == - && j == || i == && j == || i == && j == || i == && j == )
  48. {
  49. continue;
  50. }
  51. break;
  52. case :
  53. if (i == && j == - || i == && j == || i == && j == || i == && j == )
  54. {
  55. continue;
  56. }
  57. break;
  58. case :
  59. if (i == - && j == || i == && j == - || i == && j == || i == && j == )
  60. {
  61. continue;
  62. }
  63. break;
  64. default:
  65. break;
  66. }
  67. if (arr[_Pos.X + i, _Pos.Y + j] == )
  68. {
  69. result = false;
  70. }
  71. }
  72. }
  73. }
  74. return result;
  75. }
  76.  
  77. public override void Change()
  78. {
  79. switch (_curChangeTimes)
  80. {
  81. case :
  82. _range = new int[, ]{{,,},
  83. {,,},
  84. {,,}};
  85. _curChangeTimes = ;
  86. break;
  87. case :
  88. _range = new int[, ]{{,,},
  89. {,,},
  90. {,,}};
  91. _curChangeTimes = ;
  92. break;
  93. case :
  94. _range = new int[, ]{{,,},
  95. {,,},
  96. {,,}};
  97. _curChangeTimes = ;
  98. break;
  99. case :
  100. _range = new int[, ]{{,,},
  101. {,,},
  102. {,,}};
  103. _curChangeTimes = ;
  104. break;
  105. default:
  106. break;
  107. }
  108. }
  109.  
  110. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  111. {
  112. bool result = false;
  113. switch (_curChangeTimes)
  114. {
  115. case :
  116. if (_Pos.Y - != )
  117. {
  118. if (_Pos.X == )
  119. {
  120. if (arr[_Pos.X, _Pos.Y - ] == )
  121. result = true;
  122. }
  123. else
  124. {
  125. if (arr[_Pos.X - , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == )
  126. result = true;
  127. }
  128. }
  129. break;
  130. case :
  131. if (_Pos.Y != )
  132. {
  133. if (_Pos.X == -)
  134. {
  135. if (arr[_Pos.X + , _Pos.Y - ] == )
  136. result = true;
  137. }
  138. else if (_Pos.X == )
  139. {
  140. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  141. result = true;
  142. }
  143. else
  144. {
  145. if (arr[_Pos.X - , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  146. result = true;
  147. }
  148. }
  149. break;
  150. case :
  151. if (_Pos.Y - != )
  152. {
  153. if (_Pos.X == -)
  154. {
  155. if (arr[_Pos.X + , _Pos.Y - ] == )
  156. result = true;
  157. }
  158. else
  159. {
  160. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  161. result = true;
  162. }
  163. }
  164. break;
  165. case :
  166. if (_Pos.Y - != )
  167. {
  168. if (_Pos.X == -)
  169. {
  170. if (arr[_Pos.X + , _Pos.Y - ] == )
  171. result = true;
  172. }
  173. else if (_Pos.X == )
  174. {
  175. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  176. result = true;
  177. }
  178. else
  179. {
  180. if (arr[_Pos.X - , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  181. result = true;
  182. }
  183. }
  184. break;
  185. default:
  186. break;
  187. }
  188. return result;
  189. }
  190.  
  191. public override bool CanRightMove(int[,] arr, int rows, int columns)
  192. {
  193. bool result = false;
  194. switch (_curChangeTimes)
  195. {
  196. case :
  197. if (_Pos.Y + < columns - )
  198. {
  199. if (_Pos.X == )
  200. {
  201. if (arr[_Pos.X, _Pos.Y + ] == )
  202. result = true;
  203. }
  204. else
  205. {
  206. if (arr[_Pos.X - , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  207. result = true;
  208. }
  209. }
  210. break;
  211. case :
  212. if (_Pos.Y + < columns - )
  213. {
  214. if (_Pos.X == -)
  215. {
  216. if (arr[_Pos.X + , _Pos.Y + ] == )
  217. result = true;
  218. }
  219. else if (_Pos.X == )
  220. {
  221. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  222. result = true;
  223. }
  224. else
  225. {
  226. if (arr[_Pos.X - , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  227. result = true;
  228. }
  229. }
  230. break;
  231. case :
  232. if (_Pos.Y + < columns - )
  233. {
  234. if (_Pos.X == -)
  235. {
  236. if (arr[_Pos.X + , _Pos.Y + ] == )
  237. result = true;
  238. }
  239. else
  240. {
  241. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  242. result = true;
  243. }
  244. }
  245. break;
  246. case :
  247. if (_Pos.Y < columns - )
  248. {
  249. if (_Pos.X == -)
  250. {
  251. if (arr[_Pos.X + , _Pos.Y + ] == )
  252. result = true;
  253. }
  254. else if (_Pos.X == )
  255. {
  256. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  257. result = true;
  258. }
  259. else
  260. {
  261. if (arr[_Pos.X - , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  262. result = true;
  263. }
  264. }
  265. break;
  266. default:
  267. break;
  268. }
  269. return result;
  270. }
  271.  
  272. public override bool CanDownMove(int[,] arr, int rows, int columns)
  273. {
  274. bool result = false;
  275. switch (_curChangeTimes)
  276. {
  277. case :
  278. if (_Pos.X != rows - )
  279. {
  280. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  281. result = true;
  282. }
  283. break;
  284. case :
  285. if (_Pos.X + != rows - )
  286. {
  287. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  288. result = true;
  289. }
  290. break;
  291. case :
  292. if (_Pos.X + != rows - )
  293. {
  294. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y + ] == )
  295. result = true;
  296. }
  297. break;
  298. case :
  299. if (_Pos.X + != rows - )
  300. {
  301. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y - ] == )
  302. result = true;
  303. }
  304. break;
  305. default:
  306. break;
  307. }
  308. return result;
  309. }
  310.  
  311. public override int Appear()
  312. {
  313. int result = ;
  314. switch (_curChangeTimes)
  315. {
  316. case :
  317. result = ;
  318. break;
  319. case :
  320. result = -;
  321. break;
  322. case :
  323. result = -;
  324. break;
  325. case :
  326. result = -;
  327. break;
  328. default:
  329. break;
  330. }
  331. return result;
  332. }
  333. }
  334. }

Block4

  1. ///////////////////////////////////////////////////////////
  2. // Class : Class1.cs
  3. // CLRVersion : 4.0.30319.42000
  4. // NameSpace : BenNHTetris
  5. // Created on : 2018/5/31 11:42:01
  6. // Original author : JIYONGFEI
  7. // JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
  8. ///////////////////////////////////////////////////////////
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14.  
  15. namespace BenNHTetris
  16. {
  17. class Block4:Block
  18. {
  19. public Block4()
  20. {
  21. _curChangeTimes= ;
  22. _needRows = ;
  23. _needColumns = ;
  24. _range = new int[, ]{{,,},
  25. {,,},
  26. {,,}};
  27. _center = new Point(, );
  28. }
  29.  
  30. public override bool CanChange(int[,] arr, int rows, int cloumns)
  31. {
  32. bool result = true;
  33. if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
  34. {
  35. for (int i = -; i < ; i++)
  36. {
  37. for (int j = -; j < ; j++)
  38. {
  39. switch (_curChangeTimes)
  40. {
  41. case :
  42. if (i == && j == - || i == && j == || i == && j == || i == && j == )
  43. continue;
  44. break;
  45. case :
  46. if (i == - && j == || i == && j == || i == && j == - || i == && j == -)
  47. continue;
  48. break;
  49. case :
  50. if (i == - && j == - || i == - && j == || i == && j == || i == && j == )
  51. continue;
  52. break;
  53. case :
  54. if (i == - && j == || i == && j == || i == && j == || i == && j == )
  55. continue;
  56. break;
  57. default:
  58. break;
  59. }
  60. if (arr[_Pos.X + i, _Pos.Y + j] == )
  61. {
  62. result = false;
  63. goto break1;
  64. }
  65. }
  66. }
  67. }
  68. break1: return result;
  69. }
  70.  
  71. public override void Change()
  72. {
  73. switch (_curChangeTimes)
  74. {
  75. case :
  76. _range = new int[, ]{{,,},
  77. {,,},
  78. {,,}};
  79. _curChangeTimes = ;
  80. break;
  81. case :
  82. _range = new int[, ]{{,,},
  83. {,,},
  84. {,,}};
  85. _curChangeTimes = ;
  86. break;
  87. case :
  88. _range = new int[, ]{{,,},
  89. {,,},
  90. {,,}};
  91. _curChangeTimes = ;
  92. break;
  93. case :
  94. _range = new int[, ]{{,,},
  95. {,,},
  96. {,,}};
  97. _curChangeTimes = ;
  98. break;
  99. default:
  100. break;
  101. }
  102. }
  103.  
  104. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  105. {
  106. bool result = false;
  107. switch (_curChangeTimes)
  108. {
  109. case :
  110. if (_Pos.Y - > )
  111. {
  112. if (_Pos.X == -)
  113. {
  114. if (arr[_Pos.X + , _Pos.Y - ] == )
  115. result = true;
  116. }
  117. else
  118. {
  119. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  120. result = true;
  121. }
  122. }
  123. break;
  124. case :
  125. if (_Pos.Y - > )
  126. {
  127. if (_Pos.X == -)
  128. {
  129. if (arr[_Pos.X + , _Pos.Y - ] == )
  130. result = true;
  131. }
  132. else if (_Pos.X == )
  133. {
  134. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  135. result = true;
  136. }
  137. else
  138. {
  139. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  140. result = true;
  141. }
  142. }
  143. break;
  144. case :
  145. if (_Pos.Y - > )
  146. {
  147. if (_Pos.X == )
  148. {
  149. if (arr[_Pos.X, _Pos.Y - ] == )
  150. result = true;
  151. }
  152. else
  153. {
  154. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  155. result = true;
  156. }
  157. }
  158. break;
  159. case :
  160. if (_Pos.Y > )
  161. {
  162. if (_Pos.X == -)
  163. {
  164. if (arr[_Pos.X + , _Pos.Y - ] == )
  165. result = true;
  166. }
  167. else if (_Pos.X == )
  168. {
  169. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  170. result = true;
  171. }
  172. else
  173. {
  174. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y] == )
  175. result = true;
  176. }
  177. }
  178. break;
  179. default:
  180. break;
  181. }
  182. return result;
  183. }
  184.  
  185. public override bool CanRightMove(int[,] arr, int rows, int columns)
  186. {
  187. bool result = false;
  188. switch (_curChangeTimes)
  189. {
  190. case :
  191. if (_Pos.Y + < columns - )
  192. {
  193. if (_Pos.X == -)
  194. {
  195. if (arr[_Pos.X + , _Pos.Y + ] == )
  196. result = true;
  197. }
  198. else
  199. {
  200. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  201. result = true;
  202. }
  203. }
  204. break;
  205. case :
  206. if (_Pos.Y < columns - )
  207. {
  208. if (_Pos.X == -)
  209. {
  210. if (arr[_Pos.X + , _Pos.Y] == )
  211. result = true;
  212. }
  213. else if (_Pos.X == )
  214. {
  215. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X, _Pos.Y + ] == )
  216. result = true;
  217. }
  218. else
  219. {
  220. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  221. result = true;
  222. }
  223. }
  224. break;
  225. case :
  226. if (_Pos.Y + < columns - )
  227. {
  228. if (_Pos.X == )
  229. {
  230. if (arr[_Pos.X, _Pos.Y + ] == )
  231. result = true;
  232. }
  233. else
  234. {
  235. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  236. result = true;
  237. }
  238. }
  239. break;
  240. case :
  241. if (_Pos.Y + < columns - )
  242. {
  243. if (_Pos.X == -)
  244. {
  245. if (arr[_Pos.X + , _Pos.Y + ] == )
  246. result = true;
  247. }
  248. else if (_Pos.X == )
  249. {
  250. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  251. result = true;
  252. }
  253. else
  254. {
  255. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  256. result = true;
  257. }
  258. }
  259. break;
  260. default:
  261. break;
  262. }
  263. return result;
  264. }
  265.  
  266. public override bool CanDownMove(int[,] arr, int rows, int columns)
  267. {
  268. bool result = false;
  269.  
  270. switch (_curChangeTimes)
  271. {
  272. case :
  273. if (_Pos.X + < rows - )
  274. {
  275. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y - ] == )
  276. result = true;
  277. }
  278. break;
  279. case :
  280. if (_Pos.X + < rows - )
  281. {
  282. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == )
  283. result = true;
  284. }
  285. break;
  286. case :
  287. if (_Pos.X < rows - )
  288. {
  289. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y - ] == )
  290. result = true;
  291. }
  292. break;
  293. case :
  294. if (_Pos.X + < rows - )
  295. {
  296. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  297. result = true;
  298. }
  299. break;
  300. default:
  301. break;
  302. }
  303. return result;
  304. }
  305.  
  306. public override int Appear()
  307. {
  308. int result = ;
  309. switch (_curChangeTimes)
  310. {
  311. case :
  312. result = -;
  313. break;
  314. case :
  315. result = -;
  316. break;
  317. case :
  318. result = ;
  319. break;
  320. case :
  321. result = -;
  322. break;
  323. default:
  324. break;
  325. }
  326. return result;
  327. }
  328. }
  329. }

Block5

  1. ///////////////////////////////////////////////////////////
  2. // Class : Block5.cs
  3. // CLRVersion : 4.0.30319.42000
  4. // NameSpace : BenNHTetris
  5. // Created on : 2018/5/31 11:42:29
  6. // Original author : JIYONGFEI
  7. // JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
  8. ///////////////////////////////////////////////////////////
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14.  
  15. namespace BenNHTetris
  16. {
  17. class Block5:Block
  18. {
  19. public Block5()
  20. {
  21. _curChangeTimes = ;
  22. _needRows = ;
  23. _needColumns = ;
  24. _range = new int[, ]{{,,},
  25. {,,},
  26. {,,}};
  27. _center = new Point(, );
  28. }
  29. public override bool CanChange(int[,] arr, int rows, int cloumns)
  30. {
  31. bool result = true;
  32. if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
  33. {
  34. for (int i = -; i < ; i++)
  35. {
  36. for (int j = -; j < ; j++)
  37. {
  38. switch (_curChangeTimes)
  39. {
  40. case :
  41. if (i == && j == || i == && j == || i == && j == - || i == && j == )
  42. continue;
  43. break;
  44. case :
  45. if (i == - && j == - || i == && j == - || i == && j == || i == && j == )
  46. continue;
  47. break;
  48. case :
  49. if (i == - && j == || i == - && j == || i == && j == - || i == && j == )
  50. continue;
  51. break;
  52. case :
  53. if (i == - && j == || i == && j == || i == && j == || i == && j == )
  54. continue;
  55. break;
  56. default:
  57. break;
  58. }
  59. if (arr[_Pos.X + i, _Pos.Y + j] == )
  60. {
  61. result = false;
  62. goto break1;
  63. }
  64. }
  65. }
  66. }
  67. break1: return result;
  68. }
  69.  
  70. public override void Change()
  71. {
  72. switch (_curChangeTimes)
  73. {
  74. case :
  75. _range = new int[, ]{{,,},
  76. {,,},
  77. {,,}};
  78. _curChangeTimes = ;
  79. break;
  80. case :
  81. _range = new int[, ]{{,,},
  82. {,,},
  83. {,,}};
  84. _curChangeTimes = ;
  85. break;
  86. case :
  87. _range = new int[, ]{{,,},
  88. {,,},
  89. {,,}};
  90. _curChangeTimes = ;
  91. break;
  92. case :
  93. _range = new int[, ]{{,,},
  94. {,,},
  95. {,,}};
  96. _curChangeTimes = ;
  97. break;
  98. default:
  99. break;
  100. }
  101. }
  102.  
  103. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  104. {
  105. bool result = false;
  106. switch (_curChangeTimes)
  107. {
  108. case :
  109. if (_Pos.Y - > )
  110. {
  111. if (_Pos.X == -)
  112. {
  113. if (arr[_Pos.X + , _Pos.Y - ] == )
  114. result = true;
  115. }
  116. else
  117. {
  118. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  119. result = true;
  120. }
  121. }
  122. break;
  123. case :
  124. if (_Pos.Y - > )
  125. {
  126. if (_Pos.X == -)
  127. {
  128. if (arr[_Pos.X + , _Pos.Y - ] == )
  129. result = true;
  130. }
  131. else if (_Pos.X == )
  132. {
  133. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  134. result = true;
  135. }
  136. else
  137. {
  138. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  139. result = true;
  140. }
  141. }
  142. break;
  143. case :
  144. if (_Pos.Y - > )
  145. {
  146. if (_Pos.X == )
  147. {
  148. if (arr[_Pos.X, _Pos.Y - ] == )
  149. result = true;
  150. }
  151. else
  152. {
  153. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  154. result = true;
  155. }
  156. }
  157. break;
  158. case :
  159. if (_Pos.Y > )
  160. {
  161. if (_Pos.X == -)
  162. {
  163. if (arr[_Pos.X + , _Pos.Y] == )
  164. result = true;
  165. }
  166. else if (_Pos.X == )
  167. {
  168. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X, _Pos.Y - ] == )
  169. result = true;
  170. }
  171. else
  172. {
  173. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  174. result = true;
  175. }
  176. }
  177. break;
  178. default:
  179. break;
  180. }
  181. return result;
  182. }
  183.  
  184. public override bool CanRightMove(int[,] arr, int rows, int columns)
  185. {
  186. bool result = false;
  187. switch (_curChangeTimes)
  188. {
  189. case :
  190. if (_Pos.Y + < columns - )
  191. {
  192. if (_Pos.X == -)
  193. {
  194. if (arr[_Pos.X + , _Pos.Y + ] == )
  195. result = true;
  196. }
  197. else
  198. {
  199. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  200. result = true;
  201. }
  202. }
  203. break;
  204. case :
  205. if (_Pos.Y < columns - )
  206. {
  207. if (_Pos.X == -)
  208. {
  209. if (arr[_Pos.X + , _Pos.Y + ] == )
  210. result = true;
  211. }
  212. else if (_Pos.X == )
  213. {
  214. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  215. result = true;
  216. }
  217. else
  218. {
  219. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y] == )
  220. result = true;
  221. }
  222. }
  223. break;
  224. case :
  225. if (_Pos.Y + < columns - )
  226. {
  227. if (_Pos.X == )
  228. {
  229. if (arr[_Pos.X, _Pos.Y + ] == )
  230. result = true;
  231. }
  232. else
  233. {
  234. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  235. result = true;
  236. }
  237. }
  238. break;
  239. case :
  240. if (_Pos.Y + < columns - )
  241. {
  242. if (_Pos.X == -)
  243. {
  244. if (arr[_Pos.X + , _Pos.Y + ] == )
  245. result = true;
  246. }
  247. else if (_Pos.X == )
  248. {
  249. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  250. result = true;
  251. }
  252. else
  253. {
  254. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  255. result = true;
  256. }
  257. }
  258. break;
  259. default:
  260. break;
  261. }
  262. return result;
  263. }
  264.  
  265. public override bool CanDownMove(int[,] arr, int rows, int columns)
  266. {
  267. bool result = false;
  268. switch (_curChangeTimes)
  269. {
  270. case :
  271. if (_Pos.X + < rows - )
  272. {
  273. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  274. result = true;
  275. }
  276. break;
  277. case :
  278. if (_Pos.X + < rows - )
  279. {
  280. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y - ] == )
  281. result = true;
  282. }
  283. break;
  284. case :
  285. if (_Pos.X < rows - )
  286. {
  287. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X, _Pos.Y + ] == )
  288. result = true;
  289. }
  290. break;
  291. case :
  292. if (_Pos.X + < rows - )
  293. {
  294. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  295. result = true;
  296. }
  297. break;
  298. default:
  299. break;
  300. }
  301. return result;
  302. }
  303.  
  304. public override int Appear()
  305. {
  306. int result = ;
  307. switch (_curChangeTimes)
  308. {
  309. case :
  310. result = -;
  311. break;
  312. case :
  313. result = -;
  314. break;
  315. case :
  316. result = ;
  317. break;
  318. case :
  319. result = -;
  320. break;
  321. default:
  322. break;
  323. }
  324. return result;
  325. }
  326. }
  327. }

Block6

  1. ///////////////////////////////////////////////////////////
  2. // Class : Block6.cs
  3. // CLRVersion : 4.0.30319.42000
  4. // NameSpace : BenNHTetris
  5. // Created on : 2018/5/31 11:42:37
  6. // Original author : JIYONGFEI
  7. // JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
  8. ///////////////////////////////////////////////////////////
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14.  
  15. namespace BenNHTetris
  16. {
  17. class Block6:Block
  18. {
  19. public Block6()
  20. {
  21. _curChangeTimes = ;
  22. _needRows = ;
  23. _needColumns = ;
  24. _range = new int[, ]{{,,,,},
  25. {,,,,},
  26. {,,,,},
  27. {,,,,},
  28. {,,,,}};
  29. _center = new Point(, );
  30. }
  31. public override bool CanChange(int[,] arr, int rows, int cloumns)
  32. {
  33. if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
  34. {
  35. bool result = true;
  36. switch (_curChangeTimes)
  37. {
  38. case :
  39. for (int i = -; i < ; i++)
  40. {
  41. for (int j = -; j < ; j++)
  42. {
  43. if (i == - && j == || i == && j == || i == && j == || i == && j == )
  44. continue;
  45. if (arr[_Pos.X + i, _Pos.Y + j] == )
  46. {
  47. result = false;
  48. goto break1;
  49. }
  50. }
  51. }
  52. break;
  53. case :
  54. for (int i = -; i < ; i++)
  55. {
  56. for (int j = -; j < ; j++)
  57. {
  58. if (i == && j == || i == && j == || i == && j == || i == && j == )
  59. continue;
  60. if (arr[_Pos.X + i, _Pos.Y + j] == )
  61. {
  62. result = false;
  63. goto break1;
  64. }
  65. }
  66. }
  67. break;
  68. case :
  69. for (int i = -; i < ; i++)
  70. {
  71. for (int j = -; j < ; j++)
  72. {
  73. if (i == && j == - || i == && j == - || i == && j == || i == && j == )
  74. continue;
  75. if (arr[_Pos.X + i, _Pos.Y + j] == )
  76. {
  77. result = false;
  78. goto break1;
  79. }
  80. }
  81. }
  82. break;
  83. case :
  84. for (int i = -; i < ; i++)
  85. {
  86. for (int j = -; j < ; j++)
  87. {
  88. if (i == - && j == || i == - && j == || i == && j == - || i == && j == )
  89. continue;
  90. if (arr[_Pos.X + i, _Pos.Y + j] == )
  91. {
  92. result = false;
  93. goto break1;
  94. }
  95. }
  96. }
  97. break;
  98. default:
  99. break;
  100. }
  101. break1: return result;
  102. }
  103. else
  104. {
  105. return false;
  106. }
  107. }
  108.  
  109. public override void Change()
  110. {
  111. switch (_curChangeTimes)
  112. {
  113. case :
  114. _range = new int[, ]{{,,,,},
  115. {,,,,},
  116. {,,,,},
  117. {,,,,},
  118. {,,,,}};
  119. _curChangeTimes = ;
  120. break;
  121. case :
  122. _range = new int[, ]{{,,,,},
  123. {,,,,},
  124. {,,,,},
  125. {,,,,},
  126. {,,,,}};
  127. _curChangeTimes = ;
  128. break;
  129. case :
  130. _range = new int[, ]{{,,,,},
  131. {,,,,},
  132. {,,,,},
  133. {,,,,},
  134. {,,,,}};
  135. _curChangeTimes = ;
  136. break;
  137. case :
  138. _range = new int[, ]{{,,,,},
  139. {,,,,},
  140. {,,,,},
  141. {,,,,},
  142. {,,,,}};
  143. _curChangeTimes = ;
  144. break;
  145. default:
  146. break;
  147. }
  148. }
  149.  
  150. public override bool CanLeftMove(int[,] arr, int rows, int columns)
  151. {
  152. bool result = false;
  153. switch (_curChangeTimes)
  154. {
  155. case :
  156. if (_Pos.Y > )
  157. {
  158. if (_Pos.X == )
  159. {
  160. if (arr[_Pos.X, _Pos.Y - ] == )
  161. result = true;
  162. }
  163. else
  164. {
  165. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  166. result = true;
  167. }
  168. }
  169. break;
  170. case :
  171. if (_Pos.Y > )
  172. {
  173. if (_Pos.X == -)
  174. {
  175. if (arr[_Pos.X + , _Pos.Y - ] == )
  176. result = true;
  177. }
  178. else if (_Pos.X == -)
  179. {
  180. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
  181. result = true;
  182. }
  183. else
  184. {
  185. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == )
  186. result = true;
  187. }
  188. }
  189. break;
  190. case :
  191. if (_Pos.Y > )
  192. {
  193. if (_Pos.X == -)
  194. {
  195. if (arr[_Pos.X + , _Pos.Y - ] == )
  196. result = true;
  197. }
  198. else
  199. {
  200. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == )
  201. result = true;
  202. }
  203. }
  204. break;
  205. case :
  206. if (_Pos.Y > )
  207. {
  208. if (_Pos.X == )
  209. {
  210. if (arr[_Pos.X, _Pos.Y - ] == )
  211. result = true;
  212. }
  213. else if (_Pos.X == )
  214. {
  215. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  216. result = true;
  217. }
  218. else
  219. {
  220. if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
  221. result = true;
  222. }
  223. }
  224. break;
  225. default:
  226. break;
  227. }
  228. return result;
  229. }
  230.  
  231. public override bool CanRightMove(int[,] arr, int rows, int columns)
  232. {
  233. bool result = false;
  234. switch (_curChangeTimes)
  235. {
  236. case :
  237. if (_Pos.Y + < columns - )
  238. {
  239. if (_Pos.X == )
  240. {
  241. if (arr[_Pos.X, _Pos.Y + ] == )
  242. result = true;
  243. }
  244. else
  245. {
  246. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  247. result = true;
  248. }
  249. }
  250. break;
  251. case :
  252. if (_Pos.Y + < columns - )
  253. {
  254. if (_Pos.X == -)
  255. {
  256. if (arr[_Pos.X + , _Pos.Y + ] == )
  257. result = true;
  258. }
  259. else if (_Pos.X == -)
  260. {
  261. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  262. result = true;
  263. }
  264. else
  265. {
  266. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  267. result = true;
  268. }
  269. }
  270. break;
  271. case :
  272. if (_Pos.Y < columns - )
  273. {
  274. if (_Pos.X == -)
  275. {
  276. if (arr[_Pos.X + , _Pos.Y + ] == )
  277. result = true;
  278. }
  279. else
  280. {
  281. if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
  282. result = true;
  283. }
  284. }
  285. break;
  286. case :
  287. if (_Pos.Y < columns - )
  288. {
  289. if (_Pos.X == )
  290. {
  291. if (arr[_Pos.X, _Pos.Y + ] == )
  292. result = true;
  293. }
  294. else if (_Pos.X == )
  295. {
  296. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  297. result = true;
  298. }
  299. else
  300. {
  301. if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
  302. result = true;
  303. }
  304. }
  305. break;
  306. default:
  307. break;
  308. }
  309. return result;
  310. }
  311.  
  312. public override bool CanDownMove(int[,] arr, int rows, int columns)
  313. {
  314. bool result = false;
  315. switch (_curChangeTimes)
  316. {
  317. case :
  318. if (_Pos.X < rows - )
  319. {
  320. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
  321. result = true;
  322. }
  323. break;
  324. case :
  325. if (_Pos.X + < rows - )
  326. {
  327. if (_Pos.X == -)
  328. {
  329. if (arr[_Pos.X + , _Pos.Y] == )
  330. result = true;
  331. }
  332. else
  333. {
  334. if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
  335. result = true;
  336. }
  337. }
  338. break;
  339. case :
  340. if (_Pos.X + < rows - )
  341. {
  342. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == )
  343. result = true;
  344. }
  345. break;
  346. case :
  347. if (_Pos.X < rows - )
  348. {
  349. if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == )
  350. result = true;
  351. }
  352. break;
  353. default:
  354. break;
  355. }
  356. return result;
  357. }
  358.  
  359. public override int Appear()
  360. {
  361. int result = ;
  362. switch (_curChangeTimes)
  363. {
  364. case :
  365. result = ;
  366. break;
  367. case :
  368. result = -;
  369. break;
  370. case :
  371. result = -;
  372. break;
  373. case :
  374. result = -;
  375. break;
  376. default:
  377. break;
  378. }
  379. return result;
  380. }
  381. }
  382. }

Block7

 ///////////////////////////////////////////////////////////
// Class : Block7.cs
// CLRVersion : 4.0.30319.42000
// NameSpace : BenNHTetris
// Created on : 2018/5/31 11:42:44
// Original author : JIYONGFEI
// JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
///////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text; namespace BenNHTetris
{
class Block7:Block
{
public Block7()
{
_curChangeTimes = ;
_needRows = ;
_needColumns = ;
_range = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,}};
_center = new Point(, );
}
public override bool CanChange(int[,] arr, int rows, int cloumns)
{
if (_Pos.X - >= && _Pos.X + <= rows - && _Pos.Y - >= && _Pos.Y + <= cloumns - )
{
bool result = true;
switch (_curChangeTimes)
{
case :
for (int i = -; i < ; i++)
{
for (int j = -; j < ; j++)
{
if (i == - && j == || i == && j == - || i == && j == - || i == && j == )
continue;
if (arr[_Pos.X + i, _Pos.Y + j] == )
{
result = false;
goto break1;
}
}
}
break;
case :
for (int i = -; i < ; i++)
{
for (int j = -; j < ; j++)
{
if (i == - && j == || i == - && j == || i == && j == || i == && j == )
continue;
if (arr[_Pos.X + i, _Pos.Y + j] == )
{
result = false;
goto break1;
}
}
}
break;
case :
for (int i = -; i < ; i++)
{
for (int j = -; j < ; j++)
{
if (i == && j == || i == && j == || i == && j == || i == && j == )
continue;
if (arr[_Pos.X + i, _Pos.Y + j] == )
{
result = false;
goto break1;
}
}
}
break;
case :
for (int i = -; i < ; i++)
{
for (int j = -; j < ; j++)
{
if (i == && j == - || i == && j == || i == && j == || i == && j == )
continue;
if (arr[_Pos.X + i, _Pos.Y + j] == )
{
result = false;
goto break1;
}
}
}
break;
default:
break;
}
break1: return result;
}
else
{
return false;
}
} public override void Change()
{
switch (_curChangeTimes)
{
case :
_range = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,}};
_curChangeTimes = ;
break;
case :
_range = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,}};
_curChangeTimes = ;
break;
case :
_range = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,}};
_curChangeTimes = ;
break;
case :
_range = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,}};
_curChangeTimes = ;
break;
default:
break;
}
} public override bool CanLeftMove(int[,] arr, int rows, int columns)
{
bool result = false;
switch (_curChangeTimes)
{
case :
if (_Pos.Y - > )
{
if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y - ] == )
result = true;
}
else
{
if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
result = true;
}
}
break;
case :
if (_Pos.Y > )
{
if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y - ] == )
result = true;
}
else if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
result = true;
}
else
{
if (arr[_Pos.X, _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == && arr[_Pos.X - , _Pos.Y - ] == )
result = true;
}
}
break;
case :
if (_Pos.Y > )
{
if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y - ] == )
result = true;
}
else
{
if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == )
result = true;
}
}
break;
case :
if (_Pos.Y > )
{
if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y - ] == )
result = true;
}
else if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
result = true;
}
else
{
if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X, _Pos.Y - ] == )
result = true;
}
}
break;
default:
break;
}
return result;
} public override bool CanRightMove(int[,] arr, int rows, int columns)
{
bool result = false;
switch (_curChangeTimes)
{
case :
if (_Pos.Y < columns - )
{
if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y + ] == )
result = true;
}
else
{
if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
result = true;
}
}
break;
case :
if (_Pos.Y + < columns - )
{
if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y + ] == )
result = true;
}
else if (_Pos.X == )
{
if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
result = true;
}
else
{
if (arr[_Pos.X, _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == && arr[_Pos.X - , _Pos.Y + ] == )
result = true;
}
}
break;
case :
if (_Pos.Y + < columns - )
{
if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y + ] == )
result = true;
}
else
{
if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
result = true;
}
}
break;
case :
if (_Pos.Y < columns - )
{
if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y + ] == )
result = true;
}
else if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == )
result = true;
}
else
{
if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X, _Pos.Y + ] == )
result = true;
}
}
break;
default:
break;
}
return result;
} public override bool CanDownMove(int[,] arr, int rows, int columns)
{
bool result = false;
switch (_curChangeTimes)
{
case :
if (_Pos.X < rows - )
{
if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y - ] == )
result = true;
}
break;
case :
if (_Pos.X < rows - )
{
if (arr[_Pos.X + , _Pos.Y] == && arr[_Pos.X + , _Pos.Y + ] == )
result = true;
}
break;
case :
if (_Pos.X + < rows - )
{
if (arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y + ] == && arr[_Pos.X + , _Pos.Y] == )
result = true;
}
break;
case :
if (_Pos.X + < rows - )
{
if (_Pos.X == -)
{
if (arr[_Pos.X + , _Pos.Y] == )
result = true;
}
else
{
if (arr[_Pos.X + , _Pos.Y - ] == && arr[_Pos.X + , _Pos.Y] == )
result = true;
}
}
break;
default:
break;
}
return result;
} public override int Appear()
{
int result = ;
switch (_curChangeTimes)
{
case :
result = ;
break;
case :
result = ;
break;
case :
result = -;
break;
case :
result = -;
break;
default:
break;
}
return result;
}
}
}

Blocks

 ///////////////////////////////////////////////////////////
// Class : Blocks.cs
// CLRVersion : 4.0.30319.42000
// NameSpace : BenNHTetris
// Created on : 2018/5/31 14:32:10
// Original author : JIYONGFEI
// JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
///////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace BenNHTetris
{
class Blocks
{
public static ArrayList BlockList = new ArrayList();
//随机获取一个砖块
public static Block GetBlock()
{
Random random = new Random();
int index = random.Next();
Block block;
switch (index)
{
case :
block = new Block1();
break;
case :
block = new Block2();
break;
case :
block = new Block3();
break;
case :
block = new Block4();
break;
case :
block = new Block5();
break;
case :
block = new Block6();
break;
case :
block = new Block7();
break;
default:
block = new Block1();
break;
}
return block;
}
}
}

Canvas

 ///////////////////////////////////////////////////////////
// Class : Canvas.cs
// CLRVersion : 4.0.30319.42000
// NameSpace : BenNHTetris
// Created on : 2018/5/31 11:43:28
// Original author : JIYONGFEI
// JiYF笨男孩博客 : https://www.cnblogs.com/JiYF/
///////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text; namespace BenNHTetris
{
class Canvas
{
public int m_rows; //行数
public int m_columns; //列数
public int[,] m_arr; //画布二维数组
public int m_score; //分数
private Block m_curBlock = null; //当前砖块
private Block m_nextBlock = null; //下一个砖块
private int m_height; //当前高度 /// <summary>
/// 构造画布
/// </summary>
public Canvas()
{
m_rows = ; //初始20
m_columns = ; //初始20
m_arr = new int[m_rows, m_columns];
for (int i = ; i < m_rows; i++)
{
for (int j = ; j < m_columns; j++)
{
m_arr[i, j] = ;
}
}
m_score = ;
m_height = ;
} //定时器 砖块定时下降或无法下降时生成新的砖块
public bool Run()
{
//判断是否为空
lock (m_arr)
{
if (m_curBlock == null && m_nextBlock == null)
{
m_curBlock = Blocks.GetBlock();
m_nextBlock = Blocks.GetBlock();
m_nextBlock.RandomShape();
m_curBlock.SetCenterPos(m_curBlock.Appear(), m_columns / - );
SetArrayValue();
}
else if (m_curBlock == null)
{
m_curBlock = m_nextBlock;
m_nextBlock = Blocks.GetBlock();
m_nextBlock.RandomShape();
m_curBlock.SetCenterPos(m_curBlock.Appear(), m_columns / - );
SetArrayValue();
}
else
{
if (m_curBlock.CanDownMove(m_arr, m_rows, m_columns) == true)
{
ClearCurBrick();
m_curBlock.DownMove();
SetArrayValue();
}
else
{
m_curBlock = null;
SetCurHeight();
ClearRow();
}
}
if (m_score >= )
return false;
if (m_height < m_rows)
return true;
else
return false;
}
} //根据清除当前砖块在m_arr中的值
private void ClearCurBrick()
{
int centerX = m_curBlock._center.X;
int centerY = m_curBlock._center.Y;
for (int i = ; i < m_curBlock._needRows; i++)
{
for (int j = ; j < m_curBlock._needColumns; j++)
{
int realX = m_curBlock._Pos.X - (centerX - i);
int realY = m_curBlock._Pos.Y - (centerY - j);
if (realX < || realX >= m_columns || realY < || realY >= m_rows)
{
continue;
}
else
{
if (m_curBlock._range[i, j] == )
{
continue;
}
else
{
m_arr[realX, realY] = ;
}
}
}
}
} //根据当前砖块设置m_arr的值
public void SetArrayValue()
{
int centerX = m_curBlock._center.X;
int centerY = m_curBlock._center.Y;
for (int i = ; i < m_curBlock._needRows; i++)
{
for (int j = ; j < m_curBlock._needColumns; j++)
{
int realX = m_curBlock._Pos.X - (centerX - i);
int realY = m_curBlock._Pos.Y - (centerY - j);
if (realX < || realX >= m_columns || realY < || realY >= m_rows)
{
continue;
}
else
{
if (m_curBlock._range[i, j] == )
{
continue;
}
else
{
m_arr[realX, realY] = ;
}
}
}
}
} //判断当前有没有填满的行,有则消除、加分
private void ClearRow()
{
int clearrows = ;
for (int i = m_rows - m_height; i < m_rows; i++)
{
bool isfull = true;
for (int j = ; j < m_columns; j++)
{
if (m_arr[i, j] == )
{
isfull = false;
break;
}
}
if (isfull == true)
{
clearrows++;
m_score++;
for (int k = ; k < m_columns; k++)
{
m_arr[i, k] = ;
}
}
}
for (int i = m_rows - ; i > m_rows - m_height - ; i--)
{
bool isfull = true;
for (int j = ; j < m_columns; j++)
{
if (m_arr[i, j] == )
{
isfull = false;
break;
}
}
if (isfull == true)
{
int n = i;
for (int m = n - ; m > m_rows - m_height - ; m--)
{
if (n == )
{
for (int k = ; k < m_columns; k++)
{
m_arr[n, k] = ;
}
}
else
{
for (int k = ; k < m_columns; k++)
{
m_arr[n, k] = m_arr[m, k];
}
n--;
}
}
}
}
m_height -= clearrows;
} //计算当期高度
private void SetCurHeight()
{
for (int i = ; i < m_rows; i++)
{
for (int j = ; j < m_columns; j++)
{
if (m_arr[i, j] == )
{
m_height = m_rows - i;
return;
}
}
}
} //左移
public void BrickLeft()
{
lock (m_arr)
{
if (m_curBlock != null && m_curBlock.CanLeftMove(m_arr, m_rows, m_columns) == true)
{
ClearCurBrick();
m_curBlock.LeftMove();
SetArrayValue();
}
}
} //右移
public void BrickRight()
{
lock (m_arr)
{
if (m_curBlock != null && m_curBlock.CanRightMove(m_arr, m_rows, m_columns) == true)
{
ClearCurBrick();
m_curBlock.RightMove();
SetArrayValue();
}
}
} //下移
public void BrickDown()
{
lock (m_arr)
{
if (m_curBlock != null && m_curBlock.CanDownMove(m_arr, m_rows, m_columns) == true)
{
ClearCurBrick();
m_curBlock.DownMove();
SetArrayValue();
}
}
} //变形
public void BrickUp()
{
lock (m_arr)
{
if (m_curBlock != null && m_curBlock.CanChange(m_arr, m_rows, m_columns) == true)
{
ClearCurBrick();
m_curBlock.Change();
SetArrayValue();
}
}
} //
public void DrawNewxBrick(Graphics gra, float itemwidth, float itemheight)
{
int[,] arr = new int[, ]{{,,,,},
{,,,,},
{,,,,},
{,,,,},
{,,,,,}};
switch (m_nextBlock._needColumns)
{
case :
arr[, ] = ;
arr[, ] = ;
arr[, ] = ;
arr[, ] = ;
break;
case :
for (int i = , m = ; i < ; i++, m++)
{
for (int j = , n = ; j < ; j++, n++)
{
arr[i, j] = m_nextBlock._range[m, n];
}
}
break;
case :
arr = m_nextBlock._range;
break;
default:
return;
}
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
if (arr[i, j] == )
{
gra.FillRectangle(Brushes.Orange, j * itemwidth, i * itemheight, itemwidth - , itemheight - );
}
}
}
}
}
}

4.运行效果展示

初始主界面

游戏过程

游戏结束

程序源代码工程文件下载

自定义窗体源码下载

C#俄罗斯方块小游戏程序设计与简单实现的更多相关文章

  1. js实现简单的俄罗斯方块小游戏

    js实现简单的俄罗斯方块小游戏 开始 1. 创建一个宽为 200px,高为 360px 的背景容器 <!DOCTYPE html> <html lang="en" ...

  2. JavaScript小游戏实例:简单的键盘练习

    键盘是一种常用的输入设备,灵活熟练地使用键盘进行输入是计算机用户需掌握的一门基本功.下面我们编写一个简单的键盘练习游戏. 1.刺破气泡交互式小动画 在编写简单的键盘练习游戏之前,先设计一个简单地刺破气 ...

  3. 完整版本的推箱子小游戏,最简单的纯C语言打造

    /* 推箱子小游戏 1.定义绘制样式 用二维数组的方式 2.绘制图像 3.找出当前位置 4.逻辑判断,制造动作 根据数学xy轴的规律,这里使用ij 上移,行轴上升,行数减少 下移,行数下降,函数增加 ...

  4. Java经典小游戏——贪吃蛇简单实现(附源码)

    一.使用知识 Jframe GUI 双向链表 线程 二.使用工具 IntelliJ IDEA jdk 1.8 三.开发过程 3.1素材准备 首先在开发之前应该准备一些素材,已备用,我主要找了一个图片以 ...

  5. C语言编程学习开发的俄罗斯方块小游戏

    C语言是面向过程的,而C++是面向对象的 C和C++的区别: C是一个结构化语言,它的重点在于算法和数据结构.C程序的设计首要考虑的是如何通过一个过程,对输入(或环境条件)进行运算处理得到输出(或实现 ...

  6. 微信小游戏跳一跳简单手动外挂(基于adb 和 python)

    只有两个python文件,代码很简单. shell.py: #coding:utf-8 import subprocess import math import os def execute_comm ...

  7. JS练习实例--编写经典小游戏俄罗斯方块

    最近在学习JavaScript,想编一些实例练练手,之前编了个贪吃蛇,但是实现时没有注意使用面向对象的思想,实现起来也比较简单所以就不总结了,今天就总结下俄罗斯方块小游戏的思路和实现吧(需要下载代码也 ...

  8. Html5 小游戏 俄罗斯方块

    导言 在一个风和日丽的一天,看完了疯狂HTML 5+CSS 3+JavaScript讲义,跟着做了书里最后一章的俄罗斯方块小游戏,并做了一些改进,作为自己前端学习的第一站. 游戏效果: 制作思路 因为 ...

  9. “倔驴”一个h5小游戏的实现和思考(码易直播)——总结与整理

    3月23日晚上8点半(中国队火拼韩国的时候),做了一期直播分享.15年做的一个小游戏,把核心代码拿出来,现场讲写了一遍,结果后面翻车了,写错了两个地方,导致运行效果有点问题,直播边说话边写代码还真不一 ...

随机推荐

  1. Compile groovy mixed with java in Maven

    Assuming that groovy codes are in src/main/groovy and java codes are in src/main/java. We can use 2 ...

  2. Oralce sql (+) 补充

    Oracle  外连接 (1)左外连接 (左边的表不加限制)       (2)右外连接(右边的表不加限制)       (3)全外连接(左右两表都不加限制) 外连接(Outer Join) oute ...

  3. 用DirectX实现多视图渲染

    什么是多视图 一般的3D程序都只有一个视图,对应整个窗口的客户区.多视图就是在一个窗口中放置多个视图,以便从不同的角度观察模型或者场景.很多图形软件都有这个功能,比如大家熟知的3DMax就有四个视图, ...

  4. Linux之清理linux内存cache

    转自:https://www.cnblogs.com/madsnotes/articles/5740495.html 频繁的文件访问会导致系统的Cache使用量大增.例如:在使用grep从很多文件中搜 ...

  5. 【黑魔法】Covering Indexes、STRAIGHT_JOIN

    今天给大家介绍两个黑魔法,这都是压箱底的法宝.大家在使用时,一定要弄清他们的适用场景及用法,用好了,就是一把开天斧,用不好那就是画蛇添足.自从看过耗子哥(左耳朵耗子)的博客,都会给对相应专题有兴趣的小 ...

  6. SAP S/4 1610 IDES + HANA 2.0 安装

    前几天安装的都没带演示数据 ,这个版本带DEMO数据,学习比较好 我的机器配置: 内存:128G CPU:E5-2618L V4 硬盘:1T SSD 安装在VMware虚拟机中,安装完后,虚拟机大小只 ...

  7. wordclock中文模式快一个小时怎么调整

    wordclock屏幕保护,设置为中文模式,显示的时间比系统时间要快一个小时,其实软件自带的配置文件可以设置调整到正常时间……   工具/原料   wordclock 方法/步骤     桌面上右键菜 ...

  8. 自动化web前端测试,自动登录网站.目前发现最靠谱的方法是imacros

    imacros免费版 登录宏代码的示例: //首先登出URL GOTO=http://yoursite/logout.html//打开登录页面URL GOTO=http://yoursite/logi ...

  9. 每天一个linux命令(16):which

    1.命令简介 which (which) 命令的作用是在PATH变量指定的路径中搜索某个系统命令的位置并且返回第一个搜索结果.也就是说使用which命令就可以看到某个系统命令是否存在以及执行的到底是哪 ...

  10. Mac下的Chrome或Safari访问跨域设置,MBP上使用模拟器Simulator.app或iphone+Safari调试网页

    Mac下的Chrome或Safari访问跨域设置: mac下终端启动Chrome $ open -a Google\ Chrome --args --disable-web-security 或 /A ...