fork download
  1. private function rotationControlBlocks(rotationKind:String, rotationPress:Boolean, lrMoveKind:String):Boolean
  2. {
  3. if (rotationKind != lastRotationKind)
  4. {
  5. rotationNonFirstTime = false;
  6. lastRotationKind = rotationKind;
  7. }
  8. if (rotationPress == true)
  9. {
  10. rotationNonFirstTime = false;
  11. }
  12. if (rotationNonFirstTime == true)
  13. {
  14. return false;
  15. }
  16. rotationNonFirstTime = true;
  17.  
  18. if (rotationKind == rotEnum.nothing)
  19. {
  20. return false;
  21. }
  22. else
  23. {
  24. for (var x:int = 0; x < cbSize; x++)
  25. {
  26. for (var y:int = 0; y < cbSize; y++)
  27. {
  28. if (rotationKind == rotEnum.right)
  29. {
  30. aftercb[-y + cbSize - 1][x] = controlBlocks[x][y];
  31. }
  32. else if (rotationKind == rotEnum.left)
  33. {
  34. aftercb[y][-x + cbSize - 1] = controlBlocks[x][y];
  35. }
  36. else if (rotationKind == rotEnum.half)
  37. {
  38. aftercb[-x + cbSize - 1][-y + cbSize - 1] = controlBlocks[x][y];
  39. }
  40. else { throw Error("assert"); }
  41. }
  42. }
  43. }
  44.  
  45.  
  46. var bottom:int = 0;
  47. var rightend:int = 0;
  48. var leftend:int = cbxMax - 1;
  49. var afbottom:int = 0;
  50. var afrightend:int = 0;
  51. var afleftend:int = cbxMax - 1;
  52. for (x = 0; x < cbxMax; x++)
  53. {
  54. for (y = 0; y < cbyMax; y++)
  55. {
  56. if (controlBlocks[x][y] != null)
  57. {
  58. if (bottom < y) { bottom = y; }
  59. if (rightend < x) { rightend = x; }
  60. if (leftend > x) { leftend = x; }
  61. }
  62. if (aftercb[x][y] != null)
  63. {
  64. if (afbottom < y) { afbottom = y; }
  65. if (afrightend < x) { afrightend = x; }
  66. if (afleftend > x) { afleftend = x; }
  67. }
  68. }
  69. }
  70.  
  71. var center:int;
  72. var afcenter:int;
  73.  
  74. var afcbx:Number = cbx + center - afcenter;
  75. var afcby:Number = cby + bottom - afbottom;
  76.  
  77. var afcbxt:Number;
  78. var afcbyt:Number;
  79. var a:int;
  80.  
  81. for (var i:int = 0; i < cbxMax; i++)
  82. {
  83. for (var j:int = 0; j < 8; j++)
  84. {
  85. afcbxt = afcbx;
  86. afcbyt = afcby;
  87. if (lrMoveKind == lrMovEnum.right)
  88. {
  89. a = i;
  90. }
  91. else if (lrMoveKind == lrMovEnum.left)
  92. {
  93. a = i * -1;
  94. }
  95. else
  96. {
  97. if (rotationKind == rotEnum.right)
  98. {
  99. a = i;
  100. }
  101. else if (rotationKind == rotEnum.left)
  102. {
  103. a = i * -1;
  104. }
  105. else if (rotationKind == rotEnum.half)
  106. {
  107. a = i;
  108. }
  109. else
  110. {
  111. throw Error("assert");
  112. }
  113. }
  114. switch(j)
  115. {
  116. case 0:
  117. afcbxt += a;
  118. break;
  119. case 1:
  120. afcbxt -= a;
  121. break;
  122. case 2:
  123. afcbyt -= i;
  124. break;
  125. case 3:
  126. afcbxt += a;
  127. afcbyt -= i;
  128. break;
  129. case 4:
  130. afcbxt -= a;
  131. afcbyt -= i;
  132. break;
  133. case 5:
  134. afcbyt += i;
  135. break;
  136. case 6:
  137. afcbxt += a;
  138. afcbyt += i;
  139. break;
  140. case 7:
  141. afcbxt -= a;
  142. afcbyt += i;
  143. break;
  144. default:
  145. throw Error("assert");
  146. }
  147. if (blocksHitJudge(aftercb, afcbxt, afcbyt, cbxMax, cbyMax, controlBlocks, cbx, cby, cbxMax, cbyMax, false) > 0)
  148. {
  149. if (blocksHitJudge(aftercb, afcbxt, afcbyt, cbxMax, cbyMax, blockMap, 0, 0, bmxMax, bmyMax, true) <= 0)
  150. {
  151. for (x = 0; x < cbxMax; x++)
  152. {
  153. for (y = 0; y < cbyMax; y++)
  154. {
  155. controlBlocks[x][y] = aftercb[x][y];
  156. }
  157. }
  158. cbx = afcbxt;
  159. cby = afcbyt;
  160. dispatchEvent(new controlBlockEvent(controlBlockEvent.rotationOK, gameTime, 0, rotationKind, 0, cbx, cby));
  161. return true;
  162. }
  163. }
  164. }
  165. }
  166. dispatchEvent(new controlBlockEvent(controlBlockEvent.rotationNG, gameTime, 0, rotationKind, 0, cbx, cby));
  167. return false;
  168. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty