<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript"> x= 0; function move() { x+= 4; if (x<600) document.tama.style.left= x; } </script> </head> <body onLoad="setInterval('move()',25)"> <img src="tama.gif" name="tama" style="position:absolute;left:0px;top:50px;"> </body> </html> |
<body onLoad="setInterval('move()',25)"> <img src="tama.gif" name="tama" style="position:absolute;left:0px;top:50px;"> |
<script type="text/javascript"> x= 0; function move() { x+= 4; if (x<600) document.tama.style.left= x; } </script> |
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="shot.js" type="text/javascript"></script> </head> <body onLoad="setInterval('func()',25)"> <script type="text/javascript"> var cls0 = new shot("tama0", 600, 70, -4, 0); var cls1 = new shot("tama1", 600, 70, -4, 1); var cls2 = new shot("tama2", 600, 70, -4, 2); function func() { cls0.move(); cls1.move(); cls2.move(); } </script> <img src="tama.gif" id="tama0" style="position:absolute;left:600px;top:70px;"> <img src="tama.gif" id="tama1" style="position:absolute;left:600px;top:70px;"> <img src="tama.gif" id="tama2" style="position:absolute;left:600px;top:70px;"> </body> </html> |
function shot(id, x, y, xd, yd) { this.id = id; this.x = x; this.y = y; this.xd = xd; this.yd = yd; this.flg = true; this.move = function() { if (this.flg) { this.x += this.xd; this.y += this.yd; if (this.x<0 || this.x>800 || this.y<0 || this.y>400) this.flg = false; } if (this.flg) { document.getElementById(this.id).style.visibility= "visible"; document.getElementById(this.id).style.left= this.x; document.getElementById(this.id).style.top= this.y; } else document.getElementById(this.id).style.visibility= "hidden"; } } |
<head> <script src="shot.js" type="text/javascript"></script> </head> |
<body onLoad="setInterval('func()',25)"> |
var cls0 = new shot("tama0", 600, 70, -4, 0); var cls1 = new shot("tama1", 600, 70, -4, 1); var cls2 = new shot("tama2", 600, 70, -4, 2); function func() { cls0.move(); cls1.move(); cls2.move(); } |
<img src="tama.gif" id="tama0" style="position:absolute;left:600px;top:70px;"> <img src="tama.gif" id="tama1" style="position:absolute;left:600px;top:70px;"> <img src="tama.gif" id="tama2" style="position:absolute;left:600px;top:70px;"> |
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="shot.js" type="text/javascript"></script> </head> <body onLoad="setInterval('func()',25)"> <script type="text/javascript"> var cls = new Array(); for(i=0; i<10; i++) { var w = "tama" + i; var x = 3 * Math.cos((i*36)/180*Math.PI); var y = 3 * Math.sin((i*36)/180*Math.PI); cls[i] = new shot(w, 300, 200, x, y); } function func() { for(i=0; i<10; i++) cls[i].move(); } for(i=0; i<10; i++) { var w = "tama" + i; document.write('<img src="tama.gif" id="', w, '" style="position:absolute;left:300px;top:200px;">'); } </script> </body> </html> |
<head> <script src="shot.js" type="text/javascript"></script> </head> |
<body onLoad="setInterval('func()',25)"> |
var cls = new Array(); for(i=0; i<10; i++) { var w = "tama" + i; var x = 3 * Math.cos((i*36)/180*Math.PI); var y = 3 * Math.sin((i*36)/180*Math.PI); cls[i] = new shot(w, 300, 200, x, y); } |
function func() { for(i=0; i<10; i++) cls[i].move(); } |