发布时间 : 星期日 文章学习C#从俄罗斯方块开始(二)更新完毕开始阅读e1a4075b804d2b160b4ec094
///
2. /// 检测是否可以向下了 3. ///
4. ///
7. for (int y = 0; y < 4; y++) 8. {
9. for (int x = 0; x < 4; x++) 10. {
11. if (CurrentTrick[y, x] == 1) 12. {
13. //超过了背景
14. if (y + CurrentY + 1 >= 20) 15. {
16. return false; 17. }
18. if (x + CurrentX >= 14) 19. {
20. CurrentX = 13 - x; 21. }
22. if (bgGraoud[y + CurrentY + 1, x + CurrentX] == 1
)
23. {
24. return false; 25. } 26. } 27. } 28. }
29. return true; 30. }
31. ///
34. ///
37. for (int y = 0; y < 4; y++) 38. {
39. for (int x = 0; x < 4; x++) 40. {
41. if (CurrentTrick[y, x] == 1) 42. {
43. if (x + CurrentX - 1 < 0) 44. {
45. return false; 46. }
47. if (bgGraoud[y + CurrentY, x + CurrentX - 1] == 1
)
48. {
49. return false; 50. } 51. } 52. } 53. }
54. return true;
55. }
56. ///
59. ///
62. for (int y = 0; y < 4; y++) 63. {
64. for (int x = 0; x < 4; x++) 65. {
66. if (CurrentTrick[y, x] == 1) 67. {
68. if (x + CurrentX + 1 >= 14) 69. {
70. return false; 71. }
72. if (bgGraoud[y + CurrentY, x + CurrentX+1] == 1)
73. {
74. return false; 75. } 76. } 77. } 78. }
79. return true; 80. }
///
view plaincopy to clipboardprint?
1. private void Draw() 2. {
3. Graphics g = Graphics.FromImage(myImage); 4. g.Clear(this.BackColor);
5. for (int bgy = 0; bgy < 20; bgy++) 6. {
7. for (int bgx = 0; bgx < 14; bgx++) 8. {
9. if (bgGraoud[bgy, bgx] == 1) 10. { 11.
12. g.FillRectangle(new SolidBrush(Color.Blue), bgx *
20, bgy * 20, 20, 20); 13. } 14. } 15. }
16. //绘制当前的图片
17. for (int y = 0; y < 4; y++) 18. {
19. for (int x = 0; x < 4; x++) 20. {
21. if (CurrentTrick[y, x] == 1) 22. {
23. g.FillRectangle(new SolidBrush(Color.Blue), (x +
CurrentX) * 20, (y + CurrentY) * 20, 20, 20); 24. } 25. } 26. }