だれかとめてーっ!
ぴったりの数値でストップさせられたらオッケーなミニゲーム。
目次に戻る

● 設置例


「もんだい」ボタンを押すととある数値が表示されます。
「はじめ」を押すとその下のテキストボックス内の数値が高速に上昇していきますので、ぴったり指定された数で止められるよう「とまれ」ボタンを押してください。
「やりなおし」を押すと同じ数値で再チャレンジ、「もんだい」を再び押すと別の数値でチャレンジできます。

●ソース
1・JavaScript

<script type="text/javascript">
<!--
count=0;
randam=0;
function hajime() {
	count=count+1;
	document.form1.text1.value = count;
	timer=setTimeout("hajime()", 10);
}
function tomare() {
	clearTimeout(timer);
	if(count==randam){
		document.form1.text0.value = randam+" で止めてね …… ぱーふぇくとっ!!";}
	if(count>randam){
		if(count>=randam+15){
			document.form1.text0.value = randam+" で止めてね …… 遅すぎだよ!";}
		else document.form1.text0.value = randam+" で止めてね …… ちょい遅いっ!";}	
	if(count<randam){
		if(count<=randam-15){
			document.form1.text0.value = randam+" で止めてね …… 速すぎだよ!";}
		else document.form1.text0.value = randam+" で止めてね …… ちょい速いっ!";}
	
	
}
function yari() {
	count=0;
	document.form1.text1.value = count;
}
function mondai() {
	count=0;
	document.form1.text1.value = count;
	randam=Math.ceil(Math.random() * 300);
	document.form1.text0.value = randam+" で止めてね";
}
//-->
</script>

2・フォーム

<form name="form1">
<input type="text" name="text0" value="「もんだい」ボタンを押してね →" size="40">
<input type="button" value="もんだい" onclick="mondai()">
<P><input type="text" name="text1" value="0">
<input type="button" value="はじめ" onclick="hajime()">
<input type="button" value="とまれ" onclick="tomare()">
<input type="button" value="やりなおし" onclick="yari()">
</form>

●設置方法
上記の1・JavaScriptをHTMLソース内<head>〜</head>に、
2・フォームを<body>〜</body>に貼り付けてください。


目次に戻る