i have this script for a Whack a mole game, but i can't seem to make my div's pop up when I want them to by using a random number generator. This is my code:(by the way this is my first game I have ever made so it's pobably a stupid question :))
//minigame
setInterval(function() {
var randomnumber = 1 + Math.floor(Math.random() * 10);
if (randomnumber = "1") {
$('#mole1').show();
};
if (randomnumber = '2') {
$('#mole1').show();
};
if (randomnumber = 3) {
$('#mole1').show().delay(300).hide();
};
function mole4() {
if (randomnumber = 4) {
$('#mole1').show().delay(300).hide();
};
};
function mole5() {
if (randomnumber = 5) {
$('#mole1').show().delay(300).hide();
};
};
function mole6() {
if (randomnumber = 6) {
$('#mole1').show().delay(300).hide();
};
};
}, 200);
and my html that's relevant:
<div id="minigameblockholder">
<div class='moles' id="mole1"> </div>
<div class='moles' id="mole2"> </div>
<div class='moles' id="mole3"> </div>
<div class='moles' id="mole4"> </div>
<div class='moles' id="mole5"> </div>
<div class='moles' id="mole6"> </div>
<div id="scorebord"> </div>
</div>
I have not started working on my scoreboard yet so don't other correcting that. thanks in advnce, Jasper
Aucun commentaire:
Enregistrer un commentaire