Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

JEUX DES PAIRES


Information sur la source

Catégorie :Jeux Niveau : Débutant Date de création : 16/05/2005 Vu / téléchargé: 2 244 / 206

Note :
6 / 10 - par 4 personnes
6,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

Description

Cliquez pour voir la capture en taille normale
C'est un de mes premier code en js, il montre les fonction et l'utilisation de pop up avec transfere pop vers page et page vers pop. il y a aussi un petit compteur en minute (j'avais pas encore trouver comment le fair en sec)

a plus Eln
 

Source

  • <html>
  • <head>
  • <title>-- Jeux par hennuy françois--</title>
  • <SCRIPT LANGUAGE="javascript">
  • tab = new Array (12);
  • tab1 = new Array (12);
  • tab2 = new Array (12);
  • choix = "image";
  • flag = 0;
  • cpt = 0;
  • cptj = 0;
  • melangeok = 0;
  • valeurtempsdepardM = 0;
  • valeurtempsfinM = 0;
  • variable_date = 0;
  • tempsfinalM = 0;
  • for( i=1 ; i<=12 ; i++)
  • {
  • choix = "image/1/";
  • tab[i]= choix + i + ".jpg";
  • }
  • function init()
  • {
  • for(i=0 ; i<=11 ; i++)
  • {
  • /*document.images[i].src = tab[i]; */
  • document.images[i].src = "blanc.jpg";
  • }
  • cpt = 0;
  • cptj = 0;
  • }
  • function melange()
  • {
  • melangeok = 1;
  • init();
  • for (i=0 ; i<=12 ; i++)
  • {
  • tab1[i]= 0;
  • }
  • k = 0;
  • while (k < 12 )
  • {
  • n = Math.round (11 * Math.random());
  • n++;
  • if (tab1[n] == 0)
  • {
  • choix = "image/1/";
  • tab[k] = choix + n + ".jpg" ;
  • tab2[k] = n;
  • /* document.images[k].src = tab[k] ; */
  • tab1[n] = 1 ;
  • k++;
  • }
  • }
  • }
  • function affiche(n)
  • {
  • if (melangeok == 1)
  • {
  • document.images[n].src = tab[n];
  • if ( flag == 0 )
  • {
  • a = tab2[n];
  • n1 = n;
  • }
  • if ( flag == 1 )
  • {
  • b = tab2[n];
  • n2 = n;
  • flag = -1;
  • cmp(a,b,n1,n2);
  • }
  • flag++;
  • }
  • else
  • {
  • alert ("Enregistrer vous pour jouer");
  • }
  • }
  • function cmp(a,b,n1,n2)
  • {
  • if (a == b )
  • {
  • alert ("pas deux foi la meme image");
  • }
  • if ( (a == (b - 6)) || ((a - 6) == b) )
  • {
  • cptj++;
  • cpt++;
  • }
  • else
  • {
  • alert("recommencer");
  • document.images[n1].src = "blanc.jpg";
  • document.images[n2].src = "blanc.jpg";
  • cpt++;
  • }
  • if (cptj == 6 )
  • {
  • temps();
  • tempsfinalM = ( valeurtempsfinM - valeurtempsdepardM );
  • pop_up2(cpt);
  • melangeok = 0;
  • valeurtempsdepardM = 0;
  • }
  • }
  • function pop_on()
  • {
  • window.open('pop.html','nom_doc','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=200,height=150,top=100,left=400');
  • }
  • function pop_up2(cpt)
  • {
  • n_fen = window.open('pop2.html','nom_doc','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=200,height=150,top=100,left=400');
  • nom = document.initial.nom.value;
  • if (nom == "")
  • {
  • nom = "X";
  • n_fen.document.write("<body bgcolor='#cccccc'><center>" + "Bonjour " + nom + " vous devez vous enregistrez" + " <br><br><input type=button value='Fermer' onclick='self.close()'></center></body>");
  • }
  • else
  • {
  • n_fen.document.write("<body bgcolor='#cccccc'><center>" + "Bonjour " + nom + " vous avez réussi en : " + cpt + " coups et en " + tempsfinalM + " Minute(s)" + " <br><br><input type=button value='Fermer' onclick='self.close()'></center></body>");
  • melange();
  • document.initial.nom.value = "";
  • }
  • }
  • function temps()
  • {
  • variable_date = new Date();
  • if (valeurtempsdepardM == 0 )
  • {
  • valeurtempsdepardM = variable_date.getMinutes();
  • }
  • else
  • {
  • valeurtempsfinM = variable_date.getMinutes();
  • }
  • }
  • </script>
  • </head>
  • <body bgcolor="#cccccc" onload="init()">
  • <table width = 300 height = 450 border = 0 cellspacing = 0 align = center >
  • <tr>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(0)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(1)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(2)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(3)"></div></td>
  • </tr>
  • <tr>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(4)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(5)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(6)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(7)"></div></td>
  • </tr>
  • <tr>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(8)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(9)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(10)"></div></td>
  • <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(11)"></div></td>
  • </tr>
  • </table>
  • <br>
  • <form name="initial">
  • <div align="center" class="Style2">
  • Votre nom est <input type="text" name="nom" value="" disabled>
  • </div>
  • <br>
  • <div align="center">
  • <input type=button name="bouton2" value="S'enregistrer" onclick="pop_on();melange();temps()">
  • </div>
  • </form>
  • </body>
  • </html>
<html>

<head>
<title>-- Jeux par hennuy françois--</title>

<SCRIPT LANGUAGE="javascript">

tab = new Array (12);
tab1 = new Array (12);
tab2 = new Array (12);

choix = "image";
flag = 0;
cpt = 0;
cptj = 0;
melangeok = 0;
valeurtempsdepardM = 0;
valeurtempsfinM = 0;
variable_date = 0;
tempsfinalM = 0;

for( i=1 ; i<=12 ; i++)	
	{
	  choix = "image/1/";
	  tab[i]= choix + i + ".jpg";
	}
	
    
function init()
	{
	for(i=0 ; i<=11 ; i++)
		{
	        /*document.images[i].src = tab[i]; */
		document.images[i].src = "blanc.jpg";
		}

	cpt = 0;
	cptj = 0;
	}

function melange()
	 {
	 melangeok = 1;
	 
	 init();
	 
         for (i=0 ; i<=12 ; i++)
             {
              tab1[i]= 0;
             }

         k = 0;

	  while (k < 12 )
               {

               n = Math.round (11 * Math.random());
               n++;

               if (tab1[n] == 0)
                  {
		       choix = "image/1/";
		       tab[k] = choix + n + ".jpg" ;
		       tab2[k] = n;
		       /* document.images[k].src = tab[k] ; */
                       tab1[n] = 1 ;
		       k++;
                  }
               }
	 }
	 
function affiche(n)
{
if (melangeok == 1)
   {

   document.images[n].src = tab[n];

   if ( flag == 0 )
      {
      	     a = tab2[n];
  	     n1 = n;
      }

   if ( flag == 1 )
      {
      	     b = tab2[n];
  	     n2 = n;
  	     flag = -1;
  	     cmp(a,b,n1,n2);
      }
 
   flag++;

   }
else
   {
    	  alert ("Enregistrer vous pour jouer");
   }
   
}


function cmp(a,b,n1,n2)
{
if (a == b )
   {
      	 alert ("pas deux foi la meme image");
   }
   
if ( (a == (b - 6)) || ((a - 6) == b) )
 {
     	cptj++;
      	cpt++;
 }
else
 {
    	alert("recommencer");
  	document.images[n1].src = "blanc.jpg";
  	document.images[n2].src = "blanc.jpg";
  	cpt++;
 }
 if (cptj == 6 )
 {
    	  temps();
  	  tempsfinalM = ( valeurtempsfinM - valeurtempsdepardM );
  	  pop_up2(cpt);
  	  melangeok = 0;
  	  valeurtempsdepardM = 0;
 }
}

function pop_on()
{
 	 window.open('pop.html','nom_doc','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=200,height=150,top=100,left=400');
}

function pop_up2(cpt)
{
 n_fen = window.open('pop2.html','nom_doc','toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,width=200,height=150,top=100,left=400');
 nom = document.initial.nom.value;
 
 if (nom == "")
    {
     	 nom = "X";
  	 n_fen.document.write("<body bgcolor='#cccccc'><center>" + "Bonjour " + nom + " vous devez vous enregistrez" + " <br><br><input type=button  value='Fermer' onclick='self.close()'></center></body>");
    }
 else
    {
     	 n_fen.document.write("<body bgcolor='#cccccc'><center>" + "Bonjour " + nom + " vous avez réussi en : " + cpt + " coups et en " + tempsfinalM + " Minute(s)" + " <br><br><input type=button  value='Fermer' onclick='self.close()'></center></body>");
 	 melange();
 	 document.initial.nom.value = "";
    }
}

function temps()
{

variable_date = new Date();

if (valeurtempsdepardM == 0 )
    {
         valeurtempsdepardM = variable_date.getMinutes();
    }
else
    {
         valeurtempsfinM = variable_date.getMinutes();
    }
}
	 
</script>

</head>

<body bgcolor="#cccccc" onload="init()">

<table width = 300 height = 450 border = 0 cellspacing = 0 align = center >

  <tr>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(0)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(1)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(2)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(3)"></div></td>
  </tr>

  <tr>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(4)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(5)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(6)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(7)"></div></td>
  </tr>

  <tr>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(8)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(9)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(10)"></div></td>
    <td><div align="center"><img src="blanc.jpg" width="100" height="150" OnClick="affiche(11)"></div></td>
  </tr>
  
</table>

<br>

<form name="initial">

	<div align="center" class="Style2">
		Votre nom est <input type="text" name="nom" value="" disabled>
	</div>
	
	<br>
	
	<div align="center">
		<input type=button name="bouton2" value="S'enregistrer" onclick="pop_on();melange();temps()">
	</div>
	
</form>

</body>

</html>

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

signaler à un administrateur
Commentaire de Romain128 le 16/05/2005 21:28:38

J'ai pas eu trop le temps de tester, mais:
-Ca marche sous Firefox
-On ne voit pas (ou peu) la deuxieme carte qu'on retourne, a cause du message d'alerte. Essaye de le remplacer par autre chose.

signaler à un administrateur
Commentaire de arctarus le 18/05/2005 13:32:52

Pour moi il a très bien marché et sans problème d'affichage ...
Je vais quand même me plonger dans le code qui m'a l'air très intéressant .
Félicitation

signaler à un administrateur
Commentaire de coucou747 le 19/05/2005 20:21:31

ce code n'est pas mal programmé, alors je ne suis pas d'accord avec le 1... perso, je note 6 car ça reste un code basique...

N'oubli pas que l'on accède avec un id à un code !
de plus, un met :
<script type="text/javascript">
et on met toutes ses balises en minuscules...

signaler à un administrateur
Commentaire de algori le 19/05/2005 20:59:01

C'est vrai que ce 1/10 n'est absolument pas justifié.
7/10 pour remonter tout ça.
@++

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Novembre 2008
LMMJVSD
     12
3456789
10111213141516
17181920212223
24252627282930

Consulter la suite du CalendriCode



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,390 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.