hi leute. möcht ein memory spiel in javascript erstellen. anscheinend bekommt mein array bilder keine werte.
bitte um hilfe.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>::Memory::Jupi::ToM::</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/javascript"> <!-- var bilder = new Array(); var versuche = 0; var clicks = 0; var firstclick; var richtigepaare = 0;
function zufallanlegen() { for(j = 0; j<2; j++) {
for (i=1; i<7; i++) { do { do { zz = Math.round(Math.random()*100); } while ((zz < 0) || (zz > 11)) } while (bilder[zz] != null) bilder[zz] = i; } } }
function show(arrayNr) { clicks++; if (clicks == 1) { firstclick = arrayNr; } document.images[arrayNr].src = "bild" +bilder[arrayNr]+ ".jpg";
if (clicks == 2) { versuche++; clicks = 0; } if (!(bilder[arrayNr] == bilder[firstclick])) { alert("Leider Nein!"); document.images[arrayNr].src = "zu.jpg"; document.images[firstClick].src = "zu.jpg"; } else { alert("Gratulation"); richtigepaare++; } if (richtigepaare == 6) { alert("Gewonnen. Sie haben "+versuche+ " gebraucht!\nFür ein neues Spiel drücken Sie den Start-Button.");
}
}
function spielneu() { for (i = 0; i<12; i++) { document.images.src = "zu.jpg"; bilder.shift(); } versuche = 0; clicks = 0; } //--> </script>