diff --git a/mogura.css b/mogura.css new file mode 100644 index 0000000..22e7eb5 --- /dev/null +++ b/mogura.css @@ -0,0 +1,10 @@ +body {background: #804012; color: #fff; + text-align: center; vertical-align: middle;} +div {border: #ff8c00 solid 2px; background-color: #4d210b; + width: 7em; height: 7em; margin: 0 auto; border-radius: 50%;} +div img {width: 6em; margin-top: 0.3em;} +div {float: left; margin: 2% 5%;} +#message {font-size: 150%;} +#point {font-size: 150%;} +hr {clear: left;} +#memo {color: #4d210b;} diff --git a/mogura.html b/mogura.html new file mode 100644 index 0000000..6447dc2 --- /dev/null +++ b/mogura.html @@ -0,0 +1,24 @@ + + +
+ハイスコアを目指せ!!
+ + + + + + +地味に同じ場所に連続して出ないようになってるもぐぅ
+ + diff --git a/mogura.js b/mogura.js new file mode 100755 index 0000000..3b07d35 --- /dev/null +++ b/mogura.js @@ -0,0 +1,64 @@ +#!/usr/bin/env js + +(() => { + var timer = null, count = 10; point = 0; ana=6; + var tataki = ana+1; tataki2 = ana+1; //存在しないdivs添字 + var msgArea = null; ptArea = null; + function countdown() { + msgArea.innerText = `残り ${count}秒`; + if (count<=0) { + stop(); + } else { + timer = setTimeout(countdown, 1000); //1秒待つ + } + count --; + } + function start() { + startButton.disabled = true; + rand(); + countdown(); + } + function stop() { + alert("しゅーーりょーー"); + ptArea.innerText = `今回のスコア: ${point}回`; //ptArea + ptArea.style.textDecoration = "underline"; + //atari.innerHTML = "" //もぐら画像削除 + } + function whack() { // whack-a-mole(英):モグラ叩き + if (count>=0) { // 時間すぎると加算されない + point ++; + ptArea.innerText = `現在: ${point}回`; + ptArea.style.textDecoration = "none"; + atari.innerHTML = ""; //もぐら画像削除 + atari.removeEventListener('click', whack); //イベントリスナー削除 + rand(); + } + } + function rand() { + var divs = document.querySelectorAll("div"); + tataki2 = Math.floor(Math.random()*ana); + if (count>=0) { + if (tataki == tataki2) { //数字がかぶったらやり直し + rand(); + } else { + tataki = tataki2; + atari = divs[tataki]; + atari.innerHTML = "