Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stage {
- backdrop White("gallery:General/White")
- let COLS = 12;
- let ROWS = 6;
- let matrix = [ ];
- let hidelist=[];
- let db=0;
- let point=0;
- actor LogiRobi {
- costume Idle("gallery:Figures/Robot Idle")
- function createMatrix(rows, cols) {
- matrix = [ ];
- let i = 0;
- while(i < rows) {
- let list = [ ];
- let j = 0;
- while(j < cols) {
- list.push(0);
- j++;
- }
- matrix.push(list);
- i++;
- }
- }
- function createClones(n) {
- for(let i = 1; i <= n; i++) {
- createClone(Gomb);
- }
- }
- function showMatrix(rows, cols) {
- let x = -280;
- let y = 130;
- for(let i = 0; i < rows; i++) {
- for(let j = 0; j < cols; j++) {
- let item = matrix[i][j];
- item.setPosition(x, y);
- item.setCostume(Math.randomBetween(1, 3));
- item.show();
- x += 50;
- }
- y -= 50;
- x = -280;
- }
- }
- when stage.started {
- this.hide();
- this.createMatrix(ROWS, COLS);
- this.createClones(ROWS * COLS);
- this.showMatrix(ROWS, COLS);
- }
- function remove(i,j){
- let item=matrix[i][j];
- if(item){
- let color=item.costumeId;
- item.setCostume(4);
- if(i>0){
- let up=matrix[i-1][j];
- if (color==up.costumeId) {
- remove(i-1,j)
- }
- }
- if(i<ROWS-1){
- let down=matrix[i+1][j];
- if (color==down.costumeId) {
- remove(i+1,j)
- }
- }
- if(j>0){
- let left=matrix[i][j-1];
- if (color==left.costumeId) {
- remove(i,j-1)
- }
- }
- if(j<COLS-1){
- let right=matrix[i][j+1];
- if (color==right.costumeId) {
- remove(i,j+1)
- }
- }
- hidelist.push(item);
- }
- }
- function hideAndFall(){
- for(let item of hidelist){
- let I=item.i;
- let J=item.j;
- item.hide();
- matrix[I][J]=0;
- }
- }
- }
- actor Gomb {
- default costume Kék("gallery:Objects/Button Blue")
- costume Lila("gallery:Objects/Button Purple")
- costume Zöld("gallery:Objects/Button Green")
- costume Bomba_Felrobban("gallery:Objects/Bomb Explode")
- let i=0;
- let j=0;
- when stage.started {
- this.hide();
- }
- when cloned {
- let id = this.cloneId - 1;
- this.j = id % COLS;
- this.i = (id - j) / COLS;
- matrix[i][j] = this;
- }
- when clicked{
- hidelist=[];
- LogiRobi.remove(i,j);
- LogiRobi.hideAndFall();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement