49. {1,1,0,0}, 50. {0,0,0,0}, 51. {0,0,0,0} 52. } 53. }, 54. { 55. {
56. {1,0,0,0}, 57. {1,1,0,0}, 58. {0,1,0,0}, 59. {0,0,0,0} 60. }, 61. {
62. {0,1,1,0}, 63. {1,1,0,0}, 64. {0,0,0,0}, 65. {0,0,0,0} 66. }, 67. {
68. {1,0,0,0}, 69. {1,1,0,0}, 70. {0,1,0,0}, 71. {0,0,0,0} 72. }, 73. {
74. {0,1,1,0}, 75. {1,1,0,0}, 76. {0,0,0,0}, 77. {0,0,0,0} 78. } 79. }, 80. { 81. {
82. {1,1,0,0}, 83. {0,1,0,0},
84. {0,1,0,0}, 85. {0,0,0,0} 86. }, 87. {
88. {0,0,1,0}, 89. {1,1,1,0}, 90. {0,0,0,0}, 91. {0,0,0,0} 92. }, 93. {
94. {1,0,0,0}, 95. {1,0,0,0}, 96. {1,1,0,0}, 97. {0,0,0,0} 98. }, 99. {
100. {1,1,1,0}, 101. {1,0,0,0}, 102. {0,0,0,0}, 103. {0,0,0,0} 104. } 105. }}; 106.
107. #endregion 108. #region 定义背景
109. private int[,] bgGraoud ={
110. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 111. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 112. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 113. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 114. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 115. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 116. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 117. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 118. {0,0,0,0,0,0,0,0,0,0,0,0,0,0},
119. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 120. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 121. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 122. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 123. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 124. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 125. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 126. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 127. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 128. {0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 129. {0,0,0,0,0,0,0,0,0,0,0,0,0,0} 130. }; 131. #endregion
#region 定义砖块int[i,j,y,x] Tricks:i为那块砖,j为状态,y为列,x为行 private int[, , ,] Tricks = {{ { {1,0,0,0}, {1,0,0,0}, {1,0,0,0}, {1,0,0,0} }, { {1,1,1,1}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} }, { {1,0,0,0}, {1,0,0,0}, 砖块定义好了,我们还需要定义几个系统在变化的时候需要的全局变量。我在注视中写清楚了,不絮叨了。 view plaincopy to clipboardprint? 1. private int[,] CurrentTrick = new int[4, 4]; //当前的砖块
2. //CurrentTrickNum当前砖块的数目, CurrentStatusNum当前状态, CurrentX
当前x, CurrentY当前y, Sorce分数
3. private int CurrentTrickNum, CurrentStatusNum, CurrentX, CurrentY
, Sorce;
4. private int TricksNum = 4; 5. private int StatusNum = 4;
6. private Image myImage;
7. private Random rand = new Random();
private int[,] CurrentTrick = new int[4, 4]; //当前的砖块 //CurrentTrickNum当前砖块的数目, CurrentStatusNum当前状态, C private int CurrentTrickNum, CurrentStatusNum, CurrentX, C private int TricksNum = 4; private int StatusNum = 4; private Image myImage; private Random rand = new Random(); 定义好了变量,我们来想想我们的几个函数吧。首先是变化砖块,变化砖块其实就是变化砖块的状态,把砖块数组中的状态位进行循环变化即可: view plaincopy to clipboardprint? 1. ///
4. private void ChangeTricks() 5. {
6. if (CurrentStatusNum < 3) 7. {
8. CurrentStatusNum++; 9. } 10. else 11. {
12. CurrentStatusNum = 0; 13. }
14. for (int y = 0; y < 4; y++) 15. {
16. for (int x = 0; x < 4; x++) 17. {
18. CurrentTrick[y, x] = Tricks[CurrentTrickNum, CurrentS
tatusNum, y, x]; 19. } 20. } 21. }
相关推荐: