Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.65 KB | None | 0 0
  1. public class I_piece
  2. {
  3.  
  4. int x1, x2, x3, x4, y1, y2, y3, y4;
  5. uint rotation = 0;
  6.  
  7. public Point Square1
  8. {
  9. get { return new Point(x1 * 30, y1 * 30); }
  10. }
  11. public Point Square2
  12. {
  13. get { return new Point(x2 * 30, y2 * 30); }
  14. }
  15. public Point Square3
  16. {
  17. get { return new Point(x3 * 30, y3 * 30); }
  18. }
  19. public Point Square4
  20. {
  21. get { return new Point(x4 * 30, y4 * 30); }
  22. }
  23.  
  24.  
  25. public void I_Piece()
  26. {
  27. x1 = 5;
  28. y1 = 0;
  29.  
  30. x2 = 5;
  31. y2 = 1;
  32.  
  33. x3 = 5;
  34. y3 = 2;
  35.  
  36. x4 = 5;
  37. y4 = 3;
  38.  
  39. State[x1, y1] = true;
  40. State[x2, y2] = true;
  41. State[x3, y3] = true;
  42. State[x4, y4] = true;
  43. }
  44.  
  45. public void moveDown()
  46. {
  47.  
  48. if(!State[x1, y1 + 1] && !State[x2, y2 + 1] && !State[x3, y3 + 1] && !State[x4, y4 + 1])
  49. {
  50. State[x1, y1] = false;
  51. State[x2, y2] = false;
  52. State[x3, y3] = false;
  53. State[x4, y4] = false;
  54. y1++;
  55. y2++;
  56. y3++;
  57. y4++;
  58. State[x1, y1] = true;
  59. State[x2, y2] = true;
  60. State[x3, y3] = true;
  61. State[x4, y4] = true;
  62. }
  63. else
  64. {
  65. //get next piece
  66. }
  67.  
  68. }
  69.  
  70. public void rotateLeft()
  71. {
  72. if (rotation == 0)
  73. {
  74. if (!State[x1 - 2, y1 + 2] && !State[x2 - 1, y2 + 1] && !State[x4 + 1, y4 - 1])
  75. {
  76. State[x1, y1] = false;
  77. State[x2, y2] = false;
  78. State[x4, y4] = false;
  79. x1 = x1 - 2;
  80. y1 = y1 + 2;
  81. x2 = x2 - 1;
  82. y2 = y2 + 1;
  83. x4 = x4 + 1;
  84. y4 = y4 - 1;
  85. State[x1, y1] = true;
  86. State[x2, y2] = true;
  87. State[x4, y4] = true;
  88. }
  89. else
  90. {
  91. //shift to avoid collision
  92. }
  93. }
  94. if (rotation == 1)
  95. {
  96. if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
  97. {
  98. State[x1, y1] = false;
  99. State[x2, y2] = false;
  100. State[x4, y4] = false;
  101. x1 = x1 + 2;
  102. y1 = y1 + 2;
  103. x2 = x2 + 1;
  104. y2 = y2 + 1;
  105. x4 = x4 - 1;
  106. y4 = y4 - 1;
  107. State[x1, y1] = true;
  108. State[x2, y2] = true;
  109. State[x4, y4] = true;
  110. }
  111. else
  112. {
  113. //shift to avoid collision
  114. }
  115. }
  116. if (rotation == 2)
  117. {
  118. if (!State[x1 + 2, y1 - 2] && !State[x2 + 1, y2 - 1] && !State[x4 - 1, y4 + 1])
  119. {
  120. State[x1, y1] = false;
  121. State[x2, y2] = false;
  122. State[x4, y4] = false;
  123. x1 = x1 + 2;
  124. y1 = y1 - 2;
  125. x2 = x2 + 1;
  126. y2 = y2 - 1;
  127. x4 = x4 - 1;
  128. y4 = y4 + 1;
  129. State[x1, y1] = true;
  130. State[x2, y2] = true;
  131. State[x4, y4] = true;
  132. }
  133. else
  134. {
  135. //shift to avoid collision
  136. }
  137. }
  138. if (rotation == 3)
  139. {
  140. if (!State[x1 - 2, y1 - 2] && !State[x2 - 1, y2 - 1] && !State[x4 + 1, y4 + 1])
  141. {
  142. State[x1, y1] = false;
  143. State[x2, y2] = false;
  144. State[x4, y4] = false;
  145. x1 = x1 - 2;
  146. y1 = y1 - 2;
  147. x2 = x2 - 1;
  148. y2 = y2 - 1;
  149. x4 = x4 + 1;
  150. y4 = y4 + 1;
  151. State[x1, y1] = true;
  152. State[x2, y2] = true;
  153. State[x4, y4] = true;
  154. }
  155. else
  156. {
  157. //shift to avoid collision
  158. }
  159. }
  160. }
  161.  
  162. public void rotateRight()
  163. {
  164. if (rotation == 0)
  165. {
  166. if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
  167. {
  168. State[x1, y1] = false;
  169. State[x2, y2] = false;
  170. State[x4, y4] = false;
  171. x1 = x1 + 2;
  172. y1 = y1 + 2;
  173. x2 = x2 + 1;
  174. y2 = y2 + 1;
  175. x4 = x4 - 1;
  176. y4 = y4 - 1;
  177. State[x1, y1] = true;
  178. State[x2, y2] = true;
  179. State[x4, y4] = true;
  180. }
  181. else
  182. {
  183. //shift to avoid collision
  184. }
  185. }
  186. if (rotation == 1)
  187. {
  188. if (!State[x1 + 2, y1 - 2] && !State[x2 + 1, y2 - 1] && !State[x4 - 1, y4 + 1])
  189. {
  190. State[x1, y1] = false;
  191. State[x2, y2] = false;
  192. State[x4, y4] = false;
  193. x1 = x1 + 2;
  194. y1 = y1 - 2;
  195. x2 = x2 + 1;
  196. y2 = y2 - 1;
  197. x4 = x4 - 1;
  198. y4 = y4 + 1;
  199. State[x1, y1] = true;
  200. State[x2, y2] = true;
  201. State[x4, y4] = true;
  202. }
  203. else
  204. {
  205. //shift to avoid collision
  206. }
  207. }
  208. if (rotation == 2)
  209. {
  210. if (!State[x1 + 2, y1 + 2] && !State[x2 + 1, y2 + 1] && !State[x4 - 1, y4 - 1])
  211. {
  212. State[x1, y1] = false;
  213. State[x2, y2] = false;
  214. State[x4, y4] = false;
  215. x1 = x1 + 2;
  216. y1 = y1 + 2;
  217. x2 = x2 + 1;
  218. y2 = y2 + 1;
  219. x4 = x4 - 1;
  220. y4 = y4 - 1;
  221. State[x1, y1] = true;
  222. State[x2, y2] = true;
  223. State[x4, y4] = true;
  224. }
  225. else
  226. {
  227. //shift to avoid collision
  228. }
  229. }
  230. if (rotation == 3)
  231. {
  232. if (!State[x1 - 2, y1 + 2] && !State[x2 - 1, y2 + 1] && !State[x4 + 1, y4 - 1])
  233. {
  234. State[x1, y1] = false;
  235. State[x2, y2] = false;
  236. State[x4, y4] = false;
  237. x1 = x1 - 2;
  238. y1 = y1 + 2;
  239. x2 = x2 - 1;
  240. y2 = y2 + 1;
  241. x4 = x4 + 1;
  242. y4 = y4 - 1;
  243. State[x1, y1] = true;
  244. State[x2, y2] = true;
  245. State[x4, y4] = true;
  246. }
  247. else
  248. {
  249. //shift to avoid collision
  250. }
  251. }
  252. }
  253.  
  254.  
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement