アットウィキロゴ

jsx

var ball = new Array();
var bx = new Array();
var by = new Array();
var dx = new Array();
var dy = new Array();
var number;
var nx = new Array();
var ny = new Array();
var mode;
var page;
var z1 = new Array();
var z2 = new Array();
var z3 = new Array();
 
function sample(){
 
for(s=1;s<101;s++){
n1=100*Math.random();
n2=Math.floor(n1)+1;
z1[s]="http://ce00582.esy.es/may/31/ex01/gdata/"+n2+".png";  
n1=100*Math.random();
n2=Math.floor(n1)+1;
z2[s]="http://ce00582.esy.es/may/31/ex01/gdata/"+n2+".png";  
n1=100*Math.random();
n2=Math.floor(n1)+1;
z3[s]="http://ce00582.esy.es/may/31/ex01/gdata/"+n2+".png";     
}
 
page = 1;
mode = 1;
number = 100;
 
for(s=1;s<101;s++){
bx[s]=0;
by[s]=0;
dx[s]=0;
dy[s]=0;
ball[s]=0;    
}
 
for (s = 1; s < 101; s++) {
nx[s] = randn();
ny[s] = randn();
}
 
 
 
  $("#but").click(function () {
 
 
        strike();
    });
 
var timer;
var delay = 100;
 
var loop = function () {
 
    move();
 
    bomb();
 
    de();
 
    delta();
 
    if (mode == 2) page = page + 1;
    if (page > 100) page = 1;
    if (mode == 1) paint();
    if (mode == 2) paintx();
 
    stopx();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
 
 
}
 
function stopx(){
    h = 0;
    if (mode == 2) h=h + 1;
    if (Math.random()>0.9) h=h + 1;
    if (h == 2) mode = 1;
}
 
 
function delta() {
 
    for (s = 1; s < 101; s++) {
        h = 0;
        if (bx[s] > 450) h = h + 1;
        if (bx[s] < 550) h = h + 1;
        if (by[s] > 450) h = h + 1;
        if (by[s] < 550) h = h + 1;
        if (ball[s] >50) h = h + 1;
        if (mode == 1) h = h + 1;
        if (h == 6) mode = 2;
    }
 
}
 
function de(){
 
for(s=1;s<101;s++){
 h = 0;
 if (by[s] < 10) h = h + 1;
 if (ball[s] >50) h = h + 1;
 if (h == 2) ball[s] = 0;
}
 
 
}
 
function bomb(){
 
for(s=1;s<101;s++){
x1 = Math.floor(bx[s] / 10);
y1 = Math.floor(by[s] / 10);
for(sx=1;sx<101;sx++){
h=0;
if(x1==nx[sx])h=h+1;
if(y1==ny[sx])h=h+1;
if (h == 2) dx[s] = -dx[s];
if (h == 2) dy[s] = -Math.floor(0.5*dy[s]);   
}}
 
}
 
function wall() {
 
for(s=1;s<101;s++){
    h = 0;
if(bx[s]>990)h=h+1;    
if(dx[s]>0)h=h+1;
if (h == 2) dx[s] = -dx[s];
h = 0;
if(bx[s]<10)h=h+1;    
if(dx[s]<0)h=h+1;
if (h == 2) dx[s] = -dx[s];
}
 
 
}
 
function strike(){
 
 
    sx = 0;
for(s=1;s<101;s++){
if(ball[s]<50)sx=s;    
}
 
if (sx > 0) bx[sx] = 500;
if (sx > 0) by[sx] = 1000;
if (sx > 0) ball[sx] = 100;
if (sx > 0) dx[sx] =randx();
if (sx > 0) dy[sx] =0;
 
}
 
 
function randx(){
 
n1=10*Math.random();
n2=Math.floor(n1)+1;
 
return n2;
}
 
function randn(){
 
n1=100*Math.random();
n2=Math.floor(n1)+1;
 
return n2;
}
 
function move(){
 
    g = 1;
 
for(s=1;s<101;s++){
dy[s] = dy[s] - g;
}  
 
for(s=1;s<101;s++){
bx[s]=bx[s]+dx[s];
by[s] = by[s] + dy[s];
}
 
 
}
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
str=str+sub.rect(5,5,500,500,"blue"); 
 
for(s=1;s<101;s++){    
str=str+sub.rect(5*nx[s],500-5*ny[s],5,5,"green");
}
 
for(s=1;s<101;s++){    
if(ball[s]>50)str=str+sub.rect(5*bx[s]/10,500-5*by[s]/10,5,5,"red");
} 
str=str+"</svg>";
 
$("#memo").html(str);   
 
}
 
function paintx(){
 
    var str;
    str = "<table>";
    for (s = 1; s < 4; s++) {
    str = str+"<tr>";
    str = str+"<td>";
    p1 = page+s-1;
    if (p1 > 100) p1 = p1 - 100;
    str = str + pic(z1[p1]);
    str =str+ "</td>";
    str = str+"<td>";
    p1 = page+s-1;
    if (p1 > 100) p1 = p1 - 100;
    str = str + pic(z2[p1]);
    str =str+ "</td>";
    str = str+"<td>";
    p1 = page+s-1;
    if (p1 > 100) p1 = p1 - 100;
    str = str + pic(z3[p1]);
    str =str+ "</td>";
    str =str+ "</tr>";
    }
    str = str + "</table>";
 
 
    $("#memo").html(str);
 
 
 
 
}
 
function pic(pp){
 
    var str = "<img src=\""
    str = str + pp; 
    str=str+ "\" width=\"100\" height=\"100\">";
 
    return str;
}
 
最終更新:2015年05月30日 11:38