0

Candycrush code

I have to make a simple candycrush-like game code in scilab, I have managed to get elements in a matrix to move to other places, but what can I do to make those items to disappear when 3 of them have the same value, and then make the matrix replace the new free slots in it?

PLEASE HELP, ITS URGENT.

function candycrush() a=ceil(rand(8,8)*4) disp(a) f=input("Select the row you wish to move: ") c=input("Select the column you wish to move: ") m=input("Select the direction you want to move in:") t=1 //number of turns, maximum of 20// p=0 //number of points// if m==1 then temp=a(f,c) a(f,c)=a(f-1,c) a(f-1,c)=temp t=(t+1) elseif m==2 then temp=a(f,c) a(f,c)=a(f+1,c) a(f+1,c)=temp t=(t+1) elseif m==3 then temp=a(f,c) a(f,c)=a(f,c+1) a(f,c+1)=temp t=(t+1) elseif m==4 then temp=a(f,c) a(f,c)=a(f,c-1) a(f,c-1)=temp t=(t+1) end //My question is in this part of the code, when 3 items match, how to make them go and be replaced if a(f,c)=a(f-2,c) & a(f,c)=a(f-3,c) then elseif a(f,c)=a(f+2,c) & a(f,c)=a(f+3,c) then elseif a(f,c)=a(f,c+2) & a(f,c)=a(f,c+3) then elseif a(f,c)=a(f,c-2) & a(f,c)=a(f,c-3) then end //Up=1 Down=2 Right=3 Left=4// disp(a) endfunction

Scilab