ぷちぷち潰し(散乱版)

説  明
散乱した ぷちぷちをマウスでクリックして潰してください。全部潰すまでのタイムを競います。

注意事項
下記サンプルの赤字部分が画像ファイル名、青文字がぷちぷちの総数になっています。それぞれの状況に応じて書き換えてください。


動作雰囲気チェック >>実行
サンプル
<html>
<head>
<title>ぷちぷち潰し(散乱版)</title>
<script language="JavaScript"><!--
flag = false; // ゲーム中かどうかのフラグ
pW = 10; // ぷちぷちの総数
count = 0; // 潰した数
sTime = 0;
eTime = 0;
pFlag = new Array();

function pCount(n)
{
if (!flag) return; // ゲーム中でなければ処理しない
if (pFlag[n]) return; // すでに潰されている場合は処理しない
pFlag[n] = true;
document.images["puchi"+n].src = "1.gif";
count++;
if (count < pW) return;
eTime = (new Date()).getTime();
sec = (eTime - sTime) / 1000;
flag = false;
alert(sec+"秒でした\nゲームオーバー");
}

function startGame()
{
if (flag) return;
flag = true;
n = 0;
for (i=0; i<pW; i++)
{
x = Math.floor(Math.random() * document.body.clientWidth) * 0.9;
y = Math.floor(Math.random() * document.body.clientHeight) * 0.9;
document.images["puchi"+n].style.pixelLeft = x;
document.images["puchi"+n].style.pixelTop = y;
document.images["puchi"+n].src = "0.gif";
pFlag[n++] = false;
}
count = 0; // 潰した数
sTime = (new Date()).getTime();
}

function wrtImage()
{
n = 0;
for (i=0; i<pW; i++)
{
document.write("<img src='0.gif' name='puchi"+n+"' onMousedown='pCount("+n+")' style='position:absolute;top:0px;left:0px;'>");
n++;
}
}
// --></script>
</head>
<body>
ぷちぷちを潰してください。<br>
全部潰すまでの時間を競います。<br>
<br>
<form name="myForm">
<input type="button" value="Game Start" onClick="startGame()"><br>
</form>
<script language="JavaScript"><!--
wrtImage();
// --></script>
<img src="1.gif" width="1" height="1">
</body>
</html>