Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. stage {
  2.     backdrop White("gallery:General/White")
  3.     let COLS = 12;
  4.     let ROWS = 6;
  5.     let matrix = [  ];
  6.     let hidelist=[];
  7.     let db=0;
  8.     let point=0;
  9.    
  10.     actor LogiRobi {
  11.         costume Idle("gallery:Figures/Robot Idle")
  12.         function createMatrix(rows, cols) {
  13.             matrix = [  ];
  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.                 matrix.push(list);
  23.                 i++;
  24.             }
  25.         }
  26.         function createClones(n) {
  27.             for(let i = 1; i <= n; i++) {
  28.                 createClone(Gomb);
  29.             }
  30.         }
  31.         function showMatrix(rows, cols) {
  32.             let x = -280;
  33.             let y = 130;
  34.             for(let i = 0; i < rows; i++) {
  35.                 for(let j = 0; j < cols; j++) {
  36.                     let item = matrix[i][j];
  37.                     item.setPosition(x, y);
  38.                     item.setCostume(Math.randomBetween(1, 3));
  39.                     item.show();
  40.                     x += 50;
  41.                 }
  42.                 y -= 50;
  43.                 x = -280;
  44.             }
  45.         }
  46.         when stage.started {
  47.             this.hide();
  48.             this.createMatrix(ROWS, COLS);
  49.             this.createClones(ROWS * COLS);
  50.             this.showMatrix(ROWS, COLS);
  51.         }
  52.         function remove(i,j){
  53.             let item=matrix[i][j];
  54.             if(item){
  55.                 let color=item.costumeId;
  56.                 item.setCostume(4);
  57.                 if(i>0){
  58.                     let up=matrix[i-1][j];
  59.                     if (color==up.costumeId) {
  60.                         remove(i-1,j)
  61.                     }
  62.                 }
  63.                   if(i<ROWS-1){
  64.                     let down=matrix[i+1][j];
  65.                     if (color==down.costumeId) {
  66.                         remove(i+1,j)
  67.                     }
  68.                 }
  69.                   if(j>0){
  70.                     let left=matrix[i][j-1];
  71.                     if (color==left.costumeId) {
  72.                         remove(i,j-1)
  73.                     }
  74.                 }
  75.                     if(j<COLS-1){
  76.                     let right=matrix[i][j+1];
  77.                     if (color==right.costumeId) {
  78.                         remove(i,j+1)
  79.                     }
  80.                 }
  81.                 hidelist.push(item);
  82.  
  83.             }
  84.         }
  85.         function hideAndFall(){
  86.            for(let item of hidelist){
  87.                let I=item.i;
  88.                let J=item.j;
  89.                item.hide();
  90.                matrix[I][J]=0;
  91.            }
  92.         }
  93.     }
  94.    
  95.     actor Gomb {
  96.         default costume Kék("gallery:Objects/Button Blue")
  97.         costume Lila("gallery:Objects/Button Purple")
  98.         costume Zöld("gallery:Objects/Button Green")
  99.         costume Bomba_Felrobban("gallery:Objects/Bomb Explode")
  100.         let i=0;
  101.         let j=0;
  102.         when stage.started {
  103.             this.hide();
  104.         }
  105.         when cloned {
  106.             let id = this.cloneId - 1;
  107.              this.j = id % COLS;
  108.              this.i = (id - j) / COLS;
  109.             matrix[i][j] = this;
  110.         }
  111.         when clicked{
  112.             hidelist=[];
  113.             LogiRobi.remove(i,j);
  114.             LogiRobi.hideAndFall();
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement