私はWhack-A-Moleゲームを作っていますが、私は現在、この問題を抱えています。人生が人生の後に続いているのは<で、私のコードを見たい人はいますか?特に、不作為のブール値)と私が間違ってやっているものを私に伝えることができ、私はちょうど学んでいる:)ここに私のコードです:私のアプリケーションはなぜ動いていますか?
#moleWorld {
height: 330px;
width: 1500px;
margin: 0 auto;
border: 1px solid black;
}
.field {
display: inline-block;
width: 21%;
margin: 27px;
height: 21%;
border: 1px solid black;
background: red;
}
.mole {
display: inline-block;
width: 21%;
margin: 27px;
height: 21%;
border: 1px solid black;
background-color: green;
}
#generalInformation {
height: 40px;
width: 330px;
margin: 0 auto;
background: lightblue;
}
#level-display,
#lifes-display {
margin-left: 30px;
}
#beginEasyClick,
#beginNormalClick,
#beginHardClick {
margin: 40px 45%;
width: 70px;
height: 30px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="../jquery-3.1.1.js">
"use strict";
var currentScore = 2;
var niveau = 0;
var currentLives = 3;
var inAction = false;
var moleworld = "#moleWorld";
var beginEasyClick = document.getElementById("beginEasyClick");
var beginNormalClick = document.getElementById("beginNormalClick");
var beginHardClick = document.getElementById("beginHardClick");
var displayScore = document.getElementById("_displayScore");
var $field = $(moleworld).find(class = "field")
var getrandomInt(function(min, max) {
return Math.floor(Math.random() * (max - min - 1)) + min
})
function randomField() {
return Math.floor(Math.random() * 8)
}
</script>
<script>
var moleworld = "#moleWorld";
var $moleworld = $(moleworld);
currentScore = 0;
currentLives = 5;
inAction = false;
"use strict";
$().ready(function() {
$(beginEasyClick).click(function() {
if (!inAction) {
inAction = true
setInterval(function() {
spawnMole();
}, 1400);
showScore();
isThisTheMole();
}
});
function spawnMole() {
var oldScore = currentScore;
var allFields = new Array();
allFields = document.getElementsByClassName("field")
var target = $(allFields[Math.floor(Math.random() * allFields.length)])
target.addClass("mole");
setTimeout(function() {
target.removeClass("mole")
if (oldScore === currentScore) {
currentLives--;
checkLives();
}
showScore();
}, 1000)
}
function showScore() {
document.getElementById("_displayScore").innerHTML = "<span> Score : " + currentScore + " Lives : " + currentLives + "</span>"
}
$(beginNormalClick).click(function() {
// $("#car").css("background-color" , "green");
inAction = false;
});
function isThisTheMole() {
$("div>div").click(function() {
var clickedField = $(this);
if (clickedField.hasClass("mole")) {
currentScore++;
clickedField.removeClass("mole");
} else {
currentLives--;
}
showScore();
checkLives();
})
}
function checkLives() {
if (currentLives === 0) {
alert("")
inAction = false;
}
}
});
</script>
<p id="car" class="kes">blablacar</p>
<p class="kes">carblabla </p>
<div id="StartMenu"></div>
<button id="beginEasyClick"> Easy </button>
<button id="beginNormalClick"> Normal </button>
<button id="beginHardClick"> Hard </button>
<div id="generalInformation">
<p id="_displayScore"> </p>
</div>
<div id="moleWorld">
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
<div class="field"> </div>
あなたの読書のための非常に多くをありがとう!
大変ありがとうございます – THEoneANDonly