begin process at 2012 05 28 10:50:29
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Jeux

 > JEU INSPIRÉ DU RUBIK'S CUBE

JEU INSPIRÉ DU RUBIK'S CUBE


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Jeux Niveau :Initié Date de création :25/11/2004 Vu / téléchargé :9 196 / 309

Auteur : vbbreizh

Ecrire un message privé
Site perso
Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Jeu inspiré du Rubik's Cube utilisant des routines basiques et fonctionnant avec tous les navigateurs récents.

Source

  • <html><head>
  • <title>Rubiks</title>
  • <script language="JavaScript"><!--
  • //------------------chrono-----------------
  • var iHour = 0; var iMin = 0; var iSec = 0;
  • var iCount = 0; var iM=0; var iS=0;
  • function startCount(){
  • iCount++;
  • iSec = iCount;
  • if ( iSec>59 ) { iMin= iMin+1 ; iSec=0 ; iCount=0;}
  • if ( iSec<10 ) { iS= "0" +iSec;} else {iS=iSec;}
  • if ( iMin>59 ) { iHour= iHour+1 ; iMin=0;}
  • if ( iMin<10 ) { iM= "0" +iMin;} else {iM=iMin;}
  • var chrono="..." +iHour+ ":" +iM+ ":" +iS;
  • document.getElementById('clock').value=chrono;
  • setTimeout("startCount()",1000);
  • }
  • //------------------game-----------------
  • var colors= new Array('r','r','r','r','g','g','g','g','b','b','b','b','w','y','y','y');
  • //-----------------(images dans le zip)------------------------
  • var pics= new Array('red.gif','green.gif','blue.gif','yellow.gif','pix.gif');
  • var col=""; var nr;
  • var pos; var valid= false;
  • var size = colors.length;
  • function delete_element(array) {
  • size = colors.length;
  • var validNo = (nr != "NaN");
  • var inRange = ( (nr>=0) && (nr<size) );
  • if (validNo && inRange) {
  • for (var i= 0; i<=size-1; i++) {
  • colors[i] = ((i == nr) ? "delete" : colors[i]);}
  • for (var j= nr; j<size-1; j++) {
  • if (j!= size) {colors[j] = colors[j+1];}}
  • colors.length = size-1;
  • }}
  • function get_col(k) {
  • nr= Math.floor(Math.random()*(size-1));
  • if (colors[nr]=='r') {col=pics[0];}
  • if (colors[nr]=='g') {col=pics[1];}
  • if (colors[nr]=='b') {col=pics[2];}
  • if (colors[nr]=='y') {col=pics[3];}
  • if (colors[nr]=='w') {col=pics[4]; pos=k;}
  • delete_element(colors);
  • }
  • function mix_colors() {
  • self.location.reload(true);
  • }
  • function check_validity(k) {
  • var Ck=parseInt(k);
  • valid= false;
  • if ((pos==(Ck-4)) || (pos==Ck+4)) {
  • valid= true;}
  • if ((pos==(Ck-1)) && (pos!=3) && (pos!=7) && (pos!=11)) {
  • valid= true;}
  • if ((pos==(Ck+1)) && (pos!=4) && (pos!=8) && (pos!=12)) {
  • valid= true;}
  • }
  • var temp = new Image();
  • function run_game(k) {
  • check_validity(k);
  • if (valid==true) {
  • temp.src= document.images[k].src;
  • document.images[k].src= document.images[pos].src;
  • document.images[pos].src= temp.src;
  • pos =k; valid= false;}
  • }
  • --></script></head>
  • <body>
  • <font size=2><font color=black>
  • Free JavaScript provided by ©2004-<a href="http://gilles.saunier.free.fr">VB'Breizh</a><br>
  • inspired from the <a href="http://dev.rubiks.com">Rubik's</a> Cube game.<br>
  • cross browser compatibility (nntype/ietype/opera recent browsers).<hr>
  • <p>
  • <center><script>
  • document.write('<table style="cursor:pointer;"><tr>');
  • for (i=0; i<16; i++) {
  • get_col(i);
  • if ((i==4) || (i==8) || (i==12)) {document.write('</tr><tr>');};
  • document.write('<td><img src="'+col+'" name="'+i+'" width=40px height=40px onmousedown="run_game('+i+')"></td>');}
  • document.write('</tr></table>');
  • </script>
  • <img src="pix.gif" width=1px height=200px border=0>
  • <p><input type=button value="...mix..." onclick="mix_colors()">&nbsp;
  • <input type=button id="clock" value="chrono" size=6><p><font size=3>
  • ...Click on the color to move and align colors as fast as possible...</center>
  • <body onload="startCount()">
  • </body></html>
<html><head>
<title>Rubiks</title>
<script language="JavaScript"><!--
//------------------chrono-----------------
var iHour = 0; var iMin = 0; var iSec = 0;
var iCount = 0; var iM=0; var iS=0;
function startCount(){
             iCount++;
             iSec = iCount;
             if ( iSec>59 ) { iMin= iMin+1 ;  iSec=0 ; iCount=0;}
             if (  iSec<10 ) {  iS= "0" +iSec;} else {iS=iSec;}
             if ( iMin>59 ) { iHour= iHour+1 ; iMin=0;}
             if (  iMin<10 ) {  iM= "0" +iMin;} else {iM=iMin;}
var chrono="..." +iHour+ ":" +iM+ ":" +iS;
document.getElementById('clock').value=chrono;
setTimeout("startCount()",1000);
}
//------------------game-----------------
var colors= new Array('r','r','r','r','g','g','g','g','b','b','b','b','w','y','y','y');
//-----------------(images dans le zip)------------------------
var pics= new Array('red.gif','green.gif','blue.gif','yellow.gif','pix.gif');
var col=""; var nr; 
var pos; var valid= false;
var size = colors.length;
function delete_element(array) {
   size = colors.length;
   var validNo = (nr != "NaN");
   var inRange = ( (nr>=0) && (nr<size) );
   if (validNo && inRange) {
       for (var i= 0; i<=size-1; i++) {
              colors[i] = ((i == nr) ? "delete" : colors[i]);}
       for (var j= nr; j<size-1; j++) {
              if (j!= size) {colors[j] = colors[j+1];}}
colors.length = size-1;
}}
function get_col(k) {
   nr= Math.floor(Math.random()*(size-1));
   if (colors[nr]=='r') {col=pics[0];}
   if (colors[nr]=='g') {col=pics[1];}
   if (colors[nr]=='b') {col=pics[2];}
   if (colors[nr]=='y') {col=pics[3];}
   if (colors[nr]=='w') {col=pics[4]; pos=k;}
delete_element(colors);
}
function mix_colors() {
    self.location.reload(true);
}
function check_validity(k) {
    var Ck=parseInt(k); 
    valid= false;
    if ((pos==(Ck-4)) || (pos==Ck+4)) {
          valid= true;} 
    if ((pos==(Ck-1)) && (pos!=3) && (pos!=7) && (pos!=11)) {
          valid= true;}
    if ((pos==(Ck+1)) && (pos!=4) && (pos!=8) && (pos!=12)) {
          valid= true;}
}
var temp = new Image();
function run_game(k) {
  check_validity(k);
  if (valid==true) {
            temp.src= document.images[k].src; 
            document.images[k].src= document.images[pos].src; 
            document.images[pos].src= temp.src;
            pos =k; valid= false;}
}
--></script></head>
<body>
<font size=2><font color=black>
Free JavaScript provided by ©2004-<a href="http://gilles.saunier.free.fr">VB'Breizh</a><br>
inspired from the <a href="http://dev.rubiks.com">Rubik's</a> Cube game.<br>
cross browser compatibility (nntype/ietype/opera recent browsers).<hr>
<p>
<center><script>
     document.write('<table style="cursor:pointer;"><tr>');
     for (i=0; i<16; i++) {
           get_col(i);
           if ((i==4) || (i==8) || (i==12)) {document.write('</tr><tr>');};
           document.write('<td><img src="'+col+'" name="'+i+'" width=40px height=40px onmousedown="run_game('+i+')"></td>');}
document.write('</tr></table>');
</script>
<img src="pix.gif" width=1px height=200px border=0>
<p><input type=button value="...mix..." onclick="mix_colors()">&nbsp;
<input type=button id="clock" value="chrono" size=6><p><font size=3>
...Click on the color to move and align colors as fast as possible...</center>
<body onload="startCount()">
</body></html>

 Conclusion

Pour avoir la dernière version, venez faire un tour sur http://gilles.saunier.free.fr"

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

ANTI-SPAM
Source avec Zip CADRER UNE PAGE SELON LA RÉSOLUTION DE L'ÉCRAN UTILISATEUR
Source avec Zip Source avec une capture BOITES DE MESSAGE PERSONNALISÉES
Source avec une capture DIAPORAMA
Source avec Zip TIMEZONE/DÉCALAGE HORAIRE

 Sources de la même categorie

Source avec Zip Source avec une capture AVVDA : A VERY VERY DARK AFFAIRES DEMO par Cyreb
Source avec Zip Source avec une capture 3D AVEC WEBGL + MESH par Hakumbaya
SUDOKU RESOLVER (BRUTEFORECE, RÉCURSION) par amezghal
Source avec Zip MACHINE À SOUS par loicseg
Source avec Zip DOODLE JUMP EN JAVASCRIPT par Toshy62

Commentaires et avis

Commentaire de jjdagadir le 26/11/2004 16:15:41

Ouais, toujours bon Vbbreizh, dans le ludique, comme dans le tehnique...çà me rapelle les pouss-pouss de notre jeunesse !
Kenavo

Commentaire de vbbreizh le 26/11/2004 17:12:40

Salud vraz jjdagadir !.. salud va breur !..
Mont a ra mad paotr vihan ?
(...Toujours content d'avoir ta visite...)
A vechal ! Gilles

Commentaire de coucou747 le 26/11/2004 20:19:29 administrateur CS

pas mal
un défaut : on ne peut pas gagner... opu alros on ne peut pas savoir comment on doit les aligner pour gagner...

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), 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

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,872 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales