#include #include #include "affichage.h" #include #include "config.h" #include "partie.h" int main(void){ int grille[MAX_TAILLE][MAX_TAILLE]; int ligne=0, colonne=0, touche, coups; char *nom_image = NULL; int img_w = 0, img_h = 0; int l_case = 0, h_case = 0; int choix_image_fait = 0; int choix_lignes_fait = 0; int choix_colonne_fait = 0; int jeu_fini = 0; int vouloir_rejouer=1; InitialiserGraphique(); while(vouloir_rejouer ==1){ choix_image_fait = 0; choix_lignes_fait = 0; choix_colonne_fait =0; jeu_fini = 0; coups=0; ligne=0; colonne =0; /*Fenetre du menu*/ CreerFenetre(100,100,500,600); /*Le choix de l'image*/ EffacerEcran(CouleurParNom("white")); ChoisirCouleurDessin(CouleurParNom("black")); EcrireTexte(150, 50, "MENU TAQUIN", 2); EcrireTexte(30, 100, "Choisissez votre image :", 1); EcrireTexte(30, 190, "Touche 1 : Image 1", 1); EcrireTexte(30, 310, "Touche 2 : Image 2", 1); EcrireTexte(30, 430, "Touche 3 : Image 3", 1); EcrireTexte(85, 520, "Enfoncer la touche maj pour les chiffres", 1); EcrireTexte(170, 540, "ou utiliser le num pad", 1); EcrireTexte(140, 560, "(Appuyez sur q pour quitter)", 1); EcrireTexte(400, 590, "Made by Taj & Ibra", 0.5); afficher_miniatures_menu(); while(choix_image_fait == 0) { if(ToucheEnAttente()) { touche = Touche(); if(touche == XK_1 || touche == XK_KP_1) { nom_image = "image1.png"; img_w = 400; img_h = 400; choix_image_fait = 1; } else if(touche == XK_2 || touche == XK_KP_2) { nom_image = "image2.png"; img_w = 600; img_h = 600; choix_image_fait = 2; } else if(touche == XK_3 || touche == XK_KP_3) { nom_image = "image3.png"; img_w = 700; img_h = 700; choix_image_fait = 3; } else if(touche == XK_q || touche == XK_Q) { fermer_affichage(); return EXIT_SUCCESS; } } } /*Choix de la taille*/ /*Lignes*/ EffacerEcran(CouleurParNom("white")); EcrireTexte(20,30,"Combien de lignes ?",2); EcrireTexte(20,80,"Appuyez sur une touche",1); EcrireTexte(20,110,"entre 3 et 8",1); while(choix_lignes_fait ==0){ if(ToucheEnAttente()){ touche=Touche(); if (touche == XK_3 || touche == XK_KP_3) { ligne = 3; choix_lignes_fait = 1; } else if (touche == XK_4 || touche == XK_KP_4) { ligne = 4; choix_lignes_fait = 1; } else if (touche == XK_5 || touche == XK_KP_5) { ligne = 5; choix_lignes_fait = 1; } else if (touche == XK_6 || touche == XK_KP_6) { ligne = 6; choix_lignes_fait = 1; } else if (touche == XK_7 || touche == XK_KP_7) { ligne = 7; choix_lignes_fait = 1; } else if (touche == XK_8 || touche == XK_KP_8) { ligne = 8; choix_lignes_fait = 1; } if (touche == XK_q) { FermerGraphique(); return EXIT_SUCCESS; } } } /*Colonne*/ EffacerEcran(CouleurParNom("white")); EcrireTexte(20,30,"Combien de colonne ?",2); EcrireTexte(20,80,"Appuyez sur une touche",1); EcrireTexte(20,110,"entre 3 et 8",1); while(choix_colonne_fait ==0){ if(ToucheEnAttente()){ touche=Touche(); if (touche == XK_3 || touche == XK_KP_3) { colonne = 3; choix_colonne_fait = 1; } else if (touche == XK_4 || touche == XK_KP_4) { colonne = 4; choix_colonne_fait = 1; } else if (touche == XK_5 || touche == XK_KP_5) { colonne = 5; choix_colonne_fait = 1; } else if (touche == XK_6 || touche == XK_KP_6) { colonne = 6; choix_colonne_fait = 1; } else if (touche == XK_7 || touche == XK_KP_7) { colonne = 7; choix_colonne_fait = 1; } else if (touche == XK_8 || touche == XK_KP_8) { colonne = 8; choix_colonne_fait = 1; } if (touche == XK_q) { FermerGraphique(); return EXIT_SUCCESS; } } } /* CALCUL AUTO des tailles*/ l_case = img_w / colonne; h_case = img_h / ligne; FermerGraphique(); /* On met la taille de l'image pour créer la fenêtre */ init_affichage(img_w, img_h); charger_image_source(nom_image); initialiser_plateau(grille,ligne,colonne); melanger_plateau(grille,ligne,colonne); afficher_plateau(grille,ligne,colonne,coups, l_case, h_case); while(jeu_fini == 0){ if (ToucheEnAttente()){ touche = Touche(); /* Pour quitter on clique sur q */ if (touche == XK_q || touche == XK_Q) { FermerGraphique(); return 0; } /* Déplacement +on affiche la nouvelle grille */ if (deplacer(grille,ligne,colonne,touche) == 1) { coups++; afficher_plateau(grille,ligne,colonne,coups, l_case, h_case); /*On vérifie si on a gagner */ if(verifier_victoire(grille,ligne,colonne) == 1 ){ jeu_fini = 1; } } } if (SourisCliquee()) { SourisPosition(); if (deplacer_souris(grille, ligne, colonne, _X, _Y, l_case, h_case) == 1) { coups++; afficher_plateau(grille, ligne, colonne, coups, l_case, h_case); if (verifier_victoire(grille, ligne, colonne) ==1 ) { jeu_fini = 1; } } } if (jeu_fini == 1){ ChoisirCouleurDessin(CouleurParNom("white")); /* pense à utiliser img_w pour la largeur du rectangle blanc */ RemplirRectangle(50,150, img_w - 100,100); ChoisirCouleurDessin(CouleurParNom("red")); EcrireTexte(60,200,"Bravo",2); EcrireTexte(60,230,"Rejouer ? (O/N)",1); while(1) { touche = Touche(); if (touche == XK_o || touche == XK_O) { FermerGraphique(); InitialiserGraphique(); break; } if (touche == XK_n || touche == XK_N) { vouloir_rejouer = 0; break; } } } } } fermer_affichage(); return EXIT_SUCCESS; }