如何创建一个lamguage /词汇匹配游戏,如下面的游戏,以便不将图像a与自身匹配,将图像a匹配到单词(或图像b)?
或者,如何操作此游戏的代码(下面的链接),以便不匹配a到a,它匹配a到b?
<SCRIPT LANGUAGE="JavaScript" SRC="../../retour.js"></SCRIPT><STYLE type="text/CSS">.bouton { border-top-width:2; border-bottom-width:2; border-left-width:2px; border-right-width:2;border-style:solid;border-color:#CCCCCC;width:46px;height:46px; background:#FFFFFF url(../../img/assoMemi/invisibl.gif) no-repeat center;}
.essai { font-size:1em; font-family:Verdana,Arial,sans-serif;color:#FFFFFF;background:#0A3F8E;border-top-width:0; border-bottom-width:0; border-left-width:0px; border-right-width:0}
#boutonImage0 { background-image:url(../../img/assoMemi/cirque/image1.gif);}
#boutonImage1 { background-image:url(../../img/assoMemi/cirque/image2.gif); }
#boutonImage2 { background-image:url(../../img/assoMemi/cirque/image3.gif); }
#boutonImage3 { background-image:url(../../img/assoMemi/cirque/image4.gif); }
#boutonImage4 { background-image:url(../../img/assoMemi/cirque/image5.gif); }
#boutonImage5 { background-image:url(../../img/assoMemi/cirque/image6.gif); }
#boutonImage6 { background-image:url(../../img/assoMemi/cirque/image7.gif); }
#boutonImage7 { background-image:url(../../img/assoMemi/cirque/image8.gif); }
#boutonImage8 { background-image:url(../../img/assoMemi/cirque/image9.gif); }
#boutonImage9 { background-image:url(../../img/assoMemi/cirque/image10.gif); }
#boutonImage10 {background-image:url(../../img/assoMemi/cirque/image11.gif); }
#boutonImage11 { background-image:url(../../img/assoMemi/cirque/image12.gif); }
#boutonImage12 { background-image:url(../../img/assoMemi/cirque/image13.gif);}
#boutonImage13 { background-image:url(../../img/assoMemi/cirque/image14.gif); }
#boutonImage14 { background-image:url(../../img/assoMemi/cirque/image15.gif); }
#boutonImage15 { background-image:url(../../img/assoMemi/cirque/image16.gif); }
#boutonImage16 { background-image:url(../../img/assoMemi/cirque/image17.gif); }
#boutonImage17 { background-image:url(../../img/assoMemi/cirque/image18.gif); }
#boutonImage18{ background-image:url(../../img/assoMemi/cirque/image19.gif); }
#boutonImage19 { background-image:url(../../img/assoMemi/cirque/image20.gif); }
#boutonImage20 { background-image:url(../../img/assoMemi/cirque/image21.gif); }
#boutonImage21 { background-image:url(../../img/assoMemi/cirque/image22.gif); }
#boutonImage22 { background-image:url(../../img/assoMemi/cirque/image23.gif); }
#boutonImage23 { background-image:url(../../img/assoMemi/cirque/image24.gif); }
#boutonImage24 { background-image:url(../../img/assoMemi/cirque/image25.gif); }
#boutonImage25 { background-image:url(../../img/assoMemi/cirque/image26.gif); }
#boutonImage26 { background-image:url(../../img/assoMemi/cirque/image27.gif); }
#boutonImage27 { background-image:url(../../img/assoMemi/cirque/image28.gif); }
#boutonImage28 { background-image:url(../../img/assoMemi/cirque/image29.gif); }
#boutonImage29 { background-image:url(../../img/assoMemi/cirque/image30.gif); }
#boutonImage30 { background-image:url(../../img/assoMemi/cirque/image31.gif); }
#boutonImage31 { background-image:url(../../img/assoMemi/cirque/image32.gif); }
#boutonImage32 { background-image:url(../../img/assoMemi/cirque/image33.gif); }#boutonCarte { background-image:url(../../img/assoMemi/invisibl.gif); }</STYLE><BGSOUND ID="fondSon"><SCRIPT><!--
//Régine B-D ; 24/02/03
//http://perso.wanadoo.fr/jeux.lulu/
//Tous droits réservés
var nbCartes=66;
//charger "gagné"
var gagnes = new Array(5);
for (i=0; i<=4; i++) {
gagnes[i]= new Image;
gagnes[i].src="../../img/gagne"+i+".gif";
}
//test=0 joueur a la main; =1 non
var test=1;
//etat=0 pas de carte reournée; =1 1 carte ; =2 2 cartes
var etat=0;
//numero des cartes sélectionnées
var retournees=new Array (-1,-1);
//numero des boutons sélectionnés
var selectiones=new Array (-1,-1);
var cartes = new Array(nbCartes);
var lesImages = new Array(nbCartes/2);
for (i=0; i<nbCartes/2; i++) {
lesImages[i]= new Image;
lesImages[i].src="../../img/assoMemi/cirque/image"+i+".gif";
}
var couleurBoutonD="#FFFFFF";
var bons=0;
var essais=0;
var nbFois=0;
var nbErreurs=0;
var nbTemps=0;
function depart0() {
t1=setTimeout("rien()",1);
t2=setTimeout("rien()",1);
for (i=0; i<nbCartes; i++) {
if (i<nbCartes/2) {
cartes[i]=i;
} else {
cartes[i]=i-nbCartes/2+100;
}
}
depart();
}
function rien() {
}
function depart() {
test=1;
clearTimeout(t1);
clearTimeout(t2);
document.Formu.Message.value="";
for (i=0; i<nbCartes; i++) {
boutonDepart(i);
}
for (i=0; i<=25; i++) {
document.images["caseEr"+i].src="../../img/assoMemi/invisibl.gif";
}
nbErreurs=0
melange();
for (i=0; i<2; i++) {
retournees[i]=-1;
selectiones[i]=-1;
}
//effacer tableau gagné
for (i=0; i<=4; i++) {document.images["gagne"+i].src="../../img/assoMemi/invisibl.gif";}
test=0;
etat=0;
bons=0;
document.Formu.elements["secondes"].value="";
essais=0;
for (i=0; i<nbCartes; i++) {
boutonMontre(i);
}
nbTemps=0
t2=setTimeout("temps()",1500);
}
function temps() {
nbTemps+=1;
if (nbTemps<2) {sec=" seconde"} else {sec=" secondes"}
document.Formu.elements["secondes"].value="Temps : "+nbTemps+sec;
t2=setTimeout("temps()",1000);
}
function boutonDepart(x) {
document.Formu.elements["base"+x].value="";
document.Formu.elements["base"+x].style.visibility="visible";
document.Formu.elements["base"+x].id="boutonCarte";
document.Formu.elements["base"+x].style.backgroundColor=couleurBoutonD;
document.Formu.elements["base"+x].style.borderColor="#CCCCCC";
}
function boutonCache(x) {
document.Formu.elements["base"+x].style.borderColor="#CCCCCC";
}
function boutonMontre(x) {
test=1;
if (retournees[0]!=retournees[1]) {
document.Formu.elements["base"+x].style.borderColor="#FF0000";
}
if (cartes[x]<100) {
document.Formu.elements["base"+x].id="boutonImage"+cartes[x];
test=0
} else {
document.Formu.elements["base"+x].id="boutonImage"+(cartes[x]-100);
test=0;
}
}
function boutonMontreBons(x) {
document.Formu.elements["base"+x].style.borderColor="#FF0000";
}
function boutonDisparait(x) {
document.Formu.elements["base"+x].style.visibility="hidden";
}
function choix(x) {
if (test==0 && x!=selectiones[0] && x!=selectiones[1]) {
if (etat<2) {
retournees[etat]=cartes[x]%100;
selectiones[etat]=x;
etat+=1;
boutonMontre(x);
if (etat==1) {
essais+=1;
//document.Formu.elements["nbEssais"].value="Nombre d'essais : "+essais;
}
if (retournees[0]==retournees[1]) {
test=1;
boutonMontreBons(selectiones[0]);
boutonMontreBons(selectiones[1]);
bons+=1;
//t1=setTimeout ("suite()",200);
suite()
} else {
if (etat==2) {
document.images["caseEr"+nbErreurs].src="../../img/sequenti/non.gif";
nbErreurs+=1;
if (nbErreurs>25) {nbErreurs=25}
}
}
} else {
etat=0;
for (i=0; i<2; i++) {
if (retournees[0]==retournees[1]) {
boutonDisparait(selectiones[i]);
} else {
boutonCache(selectiones[i])
}
}
for (i=0; i<2; i++) {
retournees[i]=-1;
selectiones[i]=-1;
}
choix(x);
}
} else {
if (test==0 && (x==selectiones[0] || x==selectiones[1]) ) {
boutonMontre(x);
}
}
}
function suite() {
boutonDisparait(selectiones[0]);
boutonDisparait(selectiones[1]);
if (bons==nbCartes/2) {
clearTimeout(t2);
gagnperd("gagne");
nbFois+=1;
document.Formu.Message.value=nbFois+" fois";
} else {
test=0;
}
}
function melange() {
for (i=0; i<nbCartes; i++) {
n1=Math.floor(Math.random()*nbCartes);
n2=Math.floor(Math.random()*nbCartes);
while (n2==n1) {n2=Math.floor(Math.random()*nbCartes);}
n=cartes[n1];
cartes[n1]=cartes[n2];
cartes[n2]=n;
}
}
function gagnperd(x) {
for (i=0; i<=4; i++) {
document.images["gagne"+i].src=gagnes[i].src;
}
}
//--></SCRIPT>
<script type="text/javascript">
//<![CDATA[
var gs_d=new Date,DoW=gs_d.getDay();gs_d.setDate(gs_d.getDate()-(DoW+6)%7+3);
var ms=gs_d.valueOf();gs_d.setMonth(0);gs_d.setDate(4);
var gs_r=(Math.round((ms-gs_d.valueOf())/6048E5)+1)*gs_d.getFullYear();
var gs_p = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + gs_p + "s.gstat.orange.fr/lib/gs.js?"+gs_r+"' type='text/javascript'%3E%3C/script%3E"));
//]]>
</script>
</HEAD>
<BODY BGCOLOR="#0A3F8E" onload="depart0();">
<P><FORM ACTION="" METHOD=POST name=Formu>
<CENTER><A NAME=jeu></A><SCRIPT LANGUAGE=JavaScript><!--
var lignes = 6;
var colonnes = 11;
document.write("<table bgcolor='' bordercolor='' ");
document.write("align=center border=0 cellpadding=4 cellspacing=0>");
for (i = 0; i < lignes; i++) {
document.write("<TR>");
for (j = 0; j < colonnes; j++) {
document.write("<td><INPUT TYPE=button NAME=base"+(colonnes*i+j)+" VALUE='' class=bouton onmousedown='choix("+(colonnes*i+j)+");'></td>");
}
document.write("</TR>");
}
document.write("</table>");
//--></SCRIPT>
答案 0 :(得分:0)
嗯,有一种简单的方法。
为图像/单词指定特殊ID或编号。 然后,在选择图像/单词时比较两个id。