Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. stage {
  2. scene White("gallery:Generic/White")
  3. let matr = 0;
  4. let ROWS = 6;
  5. let COLS = 12;
  6.  
  7. actor Robot {
  8. @bubblePosition(0.6, 0.6)
  9. costume Idle("gallery:Figures/Robot Idle")
  10.  
  11. @editorPosition(115, 0)
  12. function CreateMatrix(rows, cols) {
  13. matr = [];
  14. let i = 0;
  15. while(i < rows) {
  16. let list = [];
  17. let j = 0;
  18. while(j < cols) {
  19. list.push(0);
  20. j++;
  21. }
  22. matr.push(list);
  23. i++;
  24. }
  25. }
  26.  
  27. @editorPosition(100, 100)
  28. function ShowMatrix(rows, cols) {
  29. let i = 0;
  30. let Y = 130;
  31. while(i < rows) {
  32. let j = 0;
  33. let X = -280;
  34. while(j < cols) {
  35. let item = matr[i][j];
  36. item.setPosition(X, Y);
  37. item.setCostume(Math.randomBetween(1, 3));
  38. item.show();
  39. X += 50;
  40. j++;
  41. }
  42. Y -= 50;
  43. i++;
  44. }
  45. }
  46.  
  47. @editorPosition(100, 100)
  48. function CreateClones(N) {
  49. for(let i = 1; i <= N; i++) {
  50. stage.createClone(Button);
  51. }
  52. }
  53.  
  54. @editorPosition(804, 81)
  55. when stage.started {
  56. CreateMatrix(ROWS, COLS);
  57. CreateClones(ROWS * COLS);
  58. this.hide();
  59. ShowMatrix(ROWS, COLS);
  60. }
  61.  
  62. function Remove(i, j) {
  63. let item = matr[i][j];
  64. if(item) {
  65. let color = item.costumeId;
  66. item.setCostume(4);
  67. if(i > 0) {
  68. let up = matr[i - 1][j];
  69. if(up.costumeId == color) {
  70. Remove(i - 1, j);
  71. }
  72. }
  73. if(i < ROWS - 1) {
  74. let down = matr[i + 1][j];
  75. if(down.costumeId == color) {
  76. Remove(i + 1, j);
  77. }
  78. }
  79. if(j > 0) {
  80. let left = matr[i][j - 1];
  81. if(left.costumeId == color) {
  82. Remove(i, j - 1);
  83. }
  84. }
  85. if(j < COLS - 1) {
  86. let right = matr[i][j + 1];
  87. if(right.costumeId == color) {
  88. Remove(i, j + 1);
  89. }
  90. }
  91. item.deleteClone();
  92. }
  93. }
  94.  
  95.  
  96. }
  97.  
  98. actor Button {
  99. @bubblePosition(0.7, 0.65)
  100. costume Blue("gallery:Objects/Button Blue")
  101. @bubblePosition(0.7, 0.65)
  102. costume Lilac("gallery:Objects/Button Purple")
  103. @bubblePosition(0.7, 0.65)
  104. costume Green("gallery:Objects/Button Green")
  105.  
  106. @editorPosition(71, 184)
  107. when cloned {
  108. let id = this.cloneId - 1;
  109. let j = id % COLS;
  110. let i = (id - j) / COLS;
  111. matr[i][j] = this;
  112. }
  113.  
  114. @editorPosition(74, 11)
  115. when stage.started {
  116. this.hide();
  117. }
  118.  
  119. }
  120.  
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement