Partage
  • Partager sur Facebook
  • Partager sur Twitter

Processing "Le jeu du Cadenas"

Problème affichage de numéro/colorie de la case...

    3 janvier 2018 à 16:53:02

    Bonjour, 

    Je cherche des gens susceptibles de m'aidé pour la création de mon jeu "cadenas" sous processing, pour mon projet d'ISN car j'ai quelques problèmes et je mis connais très peu en code et j'ai à peine les bases.

    J'ai comme projet pour mon ISN de reproduire la réplique de ce jeu et uniquement la version 2 étoiles: http://castor-informatique.fr/questions/2015/2015-FR-13-open-lock/index.html?options=%7B%22difficulty%22%3A%22easy%22%7D

    J'ai réussi à réaliser la mise en page, et je peux colorier une case. Voici ce que j'obtient pour l’instant:

    Et voici mon code:

    PImage castor;
    PImage info;
    
    int  origineGrilleX, origineGrilleY, coteGrille;    //   Déclaration des variables globales.
    
    
    
    int  colorierCaseX, colorierCaseY;                  // Coordonnées de la case à colorier.
    boolean colorierCase;                               // Colorier la case ou pas ?
    
    
    void setup() { 
      size(950, 800);
      
      
      origineGrilleX  =  350;                          //   Initialisation des variables globales.
      origineGrilleY  =  450; 
      
      coteGrille      =  50 ;
      colorierCase    = false;                        // Variable booleenne initialisée à "FAUX".
      
      stroke(0, 0, 0); 
      strokeWeight(3); 
      
      castor = loadImage("castor.png");
      Info  = loadImage("Info.png");
    }
    
    
    //disgn du jeu
    
    void draw() {
      //couleur du fond
      background(255);
      fill(0);
      textSize(18);
      text("Cliquez dans les cases ci-dessous pour modifier le code.",170,390);
            
    /* colone n°4*/
    
      fill(255, 255, 255);
      rect(350, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("0", 370, 635);
      
      fill(255, 255, 255);
      rect(400, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("1", 420, 635);
    
      fill(255, 255, 255);
      rect(450, 600, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("2", 470, 635);
    
      fill(255, 255, 255);
      rect(500, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("3", 520, 635);
    
      fill(255, 255, 255); 
      rect(550, 600, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("4", 570, 635);
    
      fill(255, 255, 255); 
      rect(600, 600, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("5", 620, 635);
    
      fill(255, 255, 255);
      rect(650, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("6", 670, 635);
    
      fill(255, 255, 255);
      rect(700, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("7", 720, 635);
    
      fill(255, 255, 255);
      rect(750, 600, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("8", 770, 635);
    
      fill(255, 255, 255);
      rect(800, 600, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("9", 820, 635);
    
    
    
    /* colone n°3*/
    
      fill(255, 255, 255); 
      rect(350, 550, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("0", 370, 585);
    
      fill(255, 255, 255); 
      rect(400, 550, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("1", 420, 585);
    
      fill(255, 255, 255);
      rect(450, 550, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("2", 470, 585);
    
      fill(255, 255, 255); 
      rect(500, 550, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("3", 520, 585);
    
      fill(255, 255, 255);
      rect(550, 550, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("4", 570, 585);
    
      fill(255, 255, 255);
      rect(600, 550, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("5", 620, 585);
    
      fill(255, 255, 255);
      rect(650, 550, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("6", 670, 585);
    
      fill(255, 255, 255);
      rect(700, 550, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("7", 720, 585);
    
      fill(255, 255, 255);
      rect(750, 550, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("8", 770, 585);
    
      fill(255, 255, 255);
      rect(800, 550, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("9", 820, 585);
    
    
      /* colone n°2*/
    
      fill(255, 255, 255);
      rect(350, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("0", 370, 535);
    
      fill(255, 255, 255);
      rect(400, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("1", 420, 535);
    
      fill(255, 255, 255); 
      rect(450, 500, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("2", 470, 535);
    
      fill(255, 255, 255);
      rect(500, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("3", 520, 535);
    
      fill(255, 255, 255); 
      rect(550, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("4", 570, 535);
    
      fill(255, 255, 255);
      rect(600, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("5", 620, 535);
    
      fill(255, 255, 255); 
      rect(650, 500, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("6", 670, 535);
    
      fill(255, 255, 255); 
      rect(700, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("7", 720, 535);
    
      fill(255, 255, 255); 
      rect(750, 500, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("8", 770, 535);
    
      fill(255, 255, 255);
      rect(800, 500, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("9", 820, 535);
    
    
     /* colone n°1*/
    
      fill(255, 255, 255);
      rect(350, 450, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("0", 370, 485);
    
      fill(255, 255, 255);
      rect(400, 450, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("1", 420, 485);
    
      fill(255, 255, 255); 
      rect(450, 450, 50, 50); 
      fill(0, 0, 0);
      textSize(25);
      text("2", 470, 485);
    
      fill(255, 255, 255); 
      rect(500, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("3", 520, 485);
    
      fill(255, 255, 255);
      rect(550, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("4", 570, 485);
    
      fill(255, 255, 255);
      rect(600, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("5", 620, 485);
    
      fill(255, 255, 255); 
      rect(650, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("6", 670, 485);
    
      fill(255, 255, 255);
      rect(700, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("7", 720, 485);
    
      fill(255, 255, 255);
      rect(750, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("8", 770, 485);
    
      fill(255, 255, 255);
      rect(800, 450, 50, 50);
      fill(0, 0, 0);
      textSize(25);
      text("9", 820, 485);
    
      
      /* Cadenas */
    
      fill(255, 255, 0); 
      rect(110, 450, 180, 200, 5);
      fill(0, 0, 0); 
      textSize(25);
      text("CADENAS", 120, 560);
    
    
    
      fill(255, 255, 255); 
      rect(250, 600, 50, 50, 5); 
    
      fill(255, 255, 255);
      rect(250, 550, 50, 50, 5); 
    
      fill(255, 255, 255);
      rect(250, 500, 50, 50, 5);
    
      fill(255, 255, 255);
      rect(250, 450, 50, 50, 5);
      
      if(colorierCase)
            {
                rect( colorierCaseX, colorierCaseY, coteGrille, coteGrille);                  // Coloriage de la case.
            }
        
      image(castor, 0,1); // pour logo concour castor  
      image(Info, 50,100); // signaux colorés  
    }
    
           
           void mousePressed() 
        {
              if( (mouseX > origineGrilleX) && (mouseX < origineGrilleX+10*coteGrille) && (mouseY > origineGrilleY) && (mouseY < origineGrilleY+4*coteGrille))
              
              {
               
                
                  colorierCaseX = origineGrilleX + coteGrille*((int)((mouseX-origineGrilleX)/coteGrille));                    //  Pour   "java" +   "javaScript".
                  colorierCaseY = origineGrilleY + coteGrille*((int)((mouseY-origineGrilleY)/coteGrille)); 
                  
                  colorierCase  = true;   
              }
              else
              {
                  colorierCase  = false;    //     Si on clique à l'extérieur du rectangle-grille, la variable booléenne est mise à "FAUX".
              }
        }
        
    



    Mes problèmes: 

    Ma case se colorie en blanc (et non en vert, sur le screen la case n°0 de la première colonne est sélectionné) de plus, cela fait disparaître le numéro de la case.

    Je peux colorier qu'une seule case sur toute la grille alors que je devrai colorier une case par colonne.

    Et pour finir je n'arrive pas à afficher le numéro de la case sélectionné sur le cadenas.

    A l'aide !

    • Partager sur Facebook
    • Partager sur Twitter

    Processing "Le jeu du Cadenas"

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown