Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stage {
- scene White("gallery:Generic/White")
- let matr = 0;
- let ROWS = 6;
- let COLS = 12;
- actor Robot {
- @bubblePosition(0.6, 0.6)
- costume Idle("gallery:Figures/Robot Idle")
- @editorPosition(115, 0)
- function CreateMatrix(rows, cols) {
- matr = [];
- let i = 0;
- while(i < rows) {
- let list = [];
- let j = 0;
- while(j < cols) {
- list.push(0);
- j++;
- }
- matr.push(list);
- i++;
- }
- }
- @editorPosition(100, 100)
- function ShowMatrix(rows, cols) {
- let i = 0;
- let Y = 130;
- while(i < rows) {
- let j = 0;
- let X = -280;
- while(j < cols) {
- let item = matr[i][j];
- item.setPosition(X, Y);
- item.setCostume(Math.randomBetween(1, 3));
- item.show();
- X += 50;
- j++;
- }
- Y -= 50;
- i++;
- }
- }
- @editorPosition(100, 100)
- function CreateClones(N) {
- for(let i = 1; i <= N; i++) {
- stage.createClone(Button);
- }
- }
- @editorPosition(804, 81)
- when stage.started {
- CreateMatrix(ROWS, COLS);
- CreateClones(ROWS * COLS);
- this.hide();
- ShowMatrix(ROWS, COLS);
- }
- function Remove(i, j) {
- let item = matr[i][j];
- if(item) {
- let color = item.costumeId;
- item.setCostume(4);
- if(i > 0) {
- let up = matr[i - 1][j];
- if(up.costumeId == color) {
- Remove(i - 1, j);
- }
- }
- if(i < ROWS - 1) {
- let down = matr[i + 1][j];
- if(down.costumeId == color) {
- Remove(i + 1, j);
- }
- }
- if(j > 0) {
- let left = matr[i][j - 1];
- if(left.costumeId == color) {
- Remove(i, j - 1);
- }
- }
- if(j < COLS - 1) {
- let right = matr[i][j + 1];
- if(right.costumeId == color) {
- Remove(i, j + 1);
- }
- }
- item.deleteClone();
- }
- }
- }
- actor Button {
- @bubblePosition(0.7, 0.65)
- costume Blue("gallery:Objects/Button Blue")
- @bubblePosition(0.7, 0.65)
- costume Lilac("gallery:Objects/Button Purple")
- @bubblePosition(0.7, 0.65)
- costume Green("gallery:Objects/Button Green")
- @editorPosition(71, 184)
- when cloned {
- let id = this.cloneId - 1;
- let j = id % COLS;
- let i = (id - j) / COLS;
- matr[i][j] = this;
- }
- @editorPosition(74, 11)
- when stage.started {
- this.hide();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement