var x=new Array();
var s,sx;
var mode;
var px,py;
function sample(){
mode=1;
point=0;
for(s=1;s<6;s++){
x[s]=new Array();
}
for(s=1;s<6;s++){
for(sx=1;sx<6;sx++){
x[s][sx]=f();
}}
change();
paint();
$("#memo").click(function(e){
x1=e.offsetX;
y1=e.offsetY;
x2=Math.floor(x1/100)+1;
y2=Math.floor(y1/100)+1;
dd=mode;
if(mode==2){
c1=x[px][py];
c2=x[x2][y2];
x[px][py]=c2;
x[x2][y2]=c1;
change();
mode=1;
}
if(dd==1)px=x2;
if(dd==1)py=y2;
if(dd==1)mode=2;
paint();
});
}
function change(){
g();
plus();
c1=count();
while(c1>50){
g();
plus();
c1=count();
rep();
}
}
function count(){
c1=0;
for(t=1;t<6;t++){
for(tx=1;tx<6;tx++){
if(x[t][tx]==0)c1=100;
}
}
return c1;
}
function plus(){
var t,tx;
for(t=1;t<5;t++){
for(tx=1;tx<6;tx++){
s1=6-t;
h=0;
if(x[tx][s1]==0)h=100;
c1=x[tx][s1];
c2=x[tx][s1-1];
if(h>50)x[tx][s1]=c2;
if(h>50)x[tx][s1-1]=c1;
}
}
}
function rep(){
var t,tx;
for(t=1;t<6;t++){
for(tx=1;tx<6;tx++){
if(x[t][tx]==0)x[t][tx]=f();
}
}
}
function g(){
var t,tx;
for(t=1;t<6;t++){
for(tx=1;tx<6;tx++){
g1(t,tx);
g2(t,tx);
}
}
}
function g1(m3,n3){
var k1,k2,k3;
k1=m3;
k2=m3+1;
k3=m3+2;
z=0;
if(k3>5)z=100;
if(k2>5)k2=5;
if(k3>5)k3=5;
c1=x[k1][n3];
c2=x[k2][n3];
c3=x[k3][n3];
de=0;
z1=0;
if(c1==c2)de=de+1;
if(c1==c3)de=de+1;
if(de==2)z1=100;
if(c1==0)z1=0;
if(z>50)z1=0;
if(z1>50){
x[k1][n3]=0;
x[k2][n3]=0;
x[k3][n3]=0;
}
}
function g2(m3,n3){
var k1,k2,k3;
k1=n3;
k2=n3+1;
k3=n3+2;
z=0;
if(k3>5)z=100;
if(k2>5)k2=5;
if(k3>5)k3=5;
c1=x[m3][k1];
c2=x[m3][k2];
c3=x[m3][k3];
de=0;
z1=0;
if(c1==c2)de=de+1;
if(c1==c3)de=de+1;
if(de==2)z1=100;
if(c1==0)z1=0;
if(z>50)z1=0;
if(z1>50){
x[m3][k1]=0;
x[m3][k2]=0;
x[m3][k3]=0;
}
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"500\" height=\"500\">";
for(s=1;s<6;s++){
for(sx=1;sx<6;sx++){
if(x[s][sx]==1)str=str+sub.rect(100*s-100,100*sx-100,100,100,"red");
if(x[s][sx]==2)str=str+sub.rect(100*s-100,100*sx-100,100,100,"green");
if(x[s][sx]==3)str=str+sub.rect(100*s-100,100*sx-100,100,100,"blue");
if(x[s][sx]==4)str=str+sub.rect(100*s-100,100*sx-100,100,100,"yellow");
if(x[s][sx]==5)str=str+sub.rect(100*s-100,100*sx-100,100,100,"pink");
if(x[s][sx]==6)str=str+sub.rect(100*s-100,100*sx-100,100,100,"brown");
}
}
str=str+"</svg>";
$("#memo").html(str);
$("#cou").html(point);
}
function f(){
n1=6*Math.random();
n2=Math.floor(n1)+1;
return n2;
}
最終更新:2016年09月28日 19:27