cIndex should be a number. imgs shouldn't be undefined, it should have the value of mines identical values. indarr should have more values than it does. some others.
beginner
Easy
medium
hard
expert
most of the variables missing var statements in the code below are declared as global variables at the start of the program. THANK YOU FOR YOUR HELP!!!
function genMines() {
var index;
var tds = table.getElementsByTagName("td");
indarr = [];
indeces = [];
//imgs = [];
var o = 0;
var q = 0;
var cntr = 0;
for(i=0, n; n = tds[i]; i++) {
mineTDS.push(n);
}
var mineCount;
for (mineCount=0;mineCount<mines;mineCount++) {
for (o = 0;o<(hw*hw);o++) {
/*do {
index = Math.floor(Math.random()*((hw*hw)-1) + 0);
checkIndex();
}
while (indarr.length<mines);*/
indeces.push(o);
}
for (q = 0;q<mines;q++) {
index = Math.floor(Math.random()*(indeces.length-1) + 0);
indarr.push(indeces[index]);
indeces.splice(index, 1);
}
for (cntr = 0;cntr<mines;cntr++) {
cIndex = parseInt(indarr[cntr]);
mineTDS[cIndex].onclick = function() {
gameOver();
};
//mineTDS[cIndex].onclick = gameOver;
var bomb = document.createElement("img");
bomb.style.display = "none";
bomb.setAttribute("src", "mine.png");
mineTDS[cIndex].appendChild(bomb);
indarr.splice(cIndex, 1);
//tds[index].onclick = gameOver;
//tds[index].className = (tdClass + " mined");
}
}
imgs = table.getElementsByTagName("img");
}

New Topic/Question
Reply


MultiQuote




|