アットウィキロゴ

おとx4

<html>
<head>
<meta charset="utf-8" />    
<script src="https://www.google.com/jsapi"></script>    
<script  src="jquery.js"></script>
<script  src="sample.js"></script>
<script  src="svgpaint.js"></script>
 </head>
<body onload="sample()">
<audio id="sp3" preload="auto">
<source src="http://www.digital.co.jp/signaling/other_contents/sound/mp3/18am01.mp3" type="audio/mp3">
</audio>    
<div id="memo" style="width: 900px; height: 500px;"></div>
</body>
</html>
 
 
 
var x=new Array();
var y=new Array();
var point=new Array();
 
function sample(){
 
mode=1; 
 
for(s=1;s<101;s++){    
x[s]=50;
y[s]=100;
point[s]=0;
}
 
 
 
var timer;
var delay = 100;
 
var loop = function () {
 
for(s=1;s<101;s++){
y[s]=y[s]-1;
}
 
for(s=1;s<101;s++){
dx=0;
r1=Math.random();
if(r1>0.7)dx=-1;
if(r1<0.3)dx=1;
 
x[s]=x[s]+dx;
 
if(x[s]>100)x[s]=100;
if(x[s]<1)x[s]=1;
 
if(y[s]<0)point[s]=0;;
 
  }
 
sx=0;
    for(s=1;s<101;s++){
    if(point[s]<50)sx=s;    
    }
 
    if(Math.random()>0.9){
    point[sx]=100;
    x[sx]=50;
    y[sx]=100;
    }
 
 check();   
 
    paint();
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();
 
 
 
 
 
 
 
 
}
 
function check(){
 
for(s=1;s<101;s++){
h=0;
if(x[s]==50)h=h+1;
if(y[s]==50)h=h+1;
if(point[s]>50)h=h+1;
if(h==3)mode=2;
}
 
 
 
}
 
 
function paint(){
 
var sub=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
for(s=1;s<101;s++){ 
if(point[s]>50)str=str+sub.rect(5*x[s],500-5*y[s],5,5,"blue");
}
if(mode==2)$( "#sp3").get(0).play() ;;
str=str+"</svg>";
 
$("#memo").html(str);   
 
mode=1; 
 
}
 
最終更新:2016年01月03日 17:19