on peut choisir le nombre de ligne et colonne mais il y a un problème de dimension de l'image, le compteur a été ajouter , mais on peut toujours pas controler avec la souris
This commit is contained in:
@@ -6,85 +6,190 @@
|
||||
#include "partie.h"
|
||||
|
||||
int main(void){
|
||||
int grille[NB_LIGNES][NB_COLS], touche;
|
||||
int grille[MAX_TAILLE][MAX_TAILLE];
|
||||
int ligne=0, colonne=0, touche, coups;
|
||||
char *nom_image = NULL;
|
||||
int choix_fait = 0,jeu_fini = 0;
|
||||
int choix_image_fait = 0;
|
||||
int choix_lignes_fait = 0;
|
||||
int choix_colonne_fait = 0;
|
||||
int jeu_fini = 0;
|
||||
int vouloir_rejouer=1;
|
||||
|
||||
init_affichage();
|
||||
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
|
||||
EcrireTexte(50, 50, "MENU TAQUIN", 2);
|
||||
EcrireTexte(50, 100, "Choisissez votre image :", 1);
|
||||
EcrireTexte(50, 150, "Touche 1 : Image 1", 1);
|
||||
EcrireTexte(50, 180, "Touche 2 : Image 2", 1);
|
||||
EcrireTexte(50, 210, "Touche 3 : Image 3", 1);
|
||||
EcrireTexte(50, 300, "(Appuyez sur q pour quitter)", 1);
|
||||
|
||||
while(choix_fait == 0) {
|
||||
if(ToucheEnAttente()) {
|
||||
touche = Touche();
|
||||
|
||||
|
||||
if(touche == XK_1 || touche == XK_KP_1) {
|
||||
nom_image = "image1.png";
|
||||
choix_fait = 1;
|
||||
}
|
||||
else if(touche == XK_2 || touche == XK_KP_2) {
|
||||
nom_image = "image2.png";
|
||||
choix_fait = 2;
|
||||
}
|
||||
else if(touche == XK_3 || touche == XK_KP_3) {
|
||||
nom_image = "image3.png";
|
||||
choix_fait = 3;
|
||||
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,400,400);
|
||||
/*Le choix de l'image*/
|
||||
|
||||
EffacerEcran(CouleurParNom("white"));
|
||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||
|
||||
EcrireTexte(50, 50, "MENU TAQUIN", 2);
|
||||
EcrireTexte(50, 100, "Choisissez votre image :", 1);
|
||||
EcrireTexte(50, 150, "Touche 1 : Image 1", 1);
|
||||
EcrireTexte(50, 180, "Touche 2 : Image 2", 1);
|
||||
EcrireTexte(50, 210, "Touche 3 : Image 3", 1);
|
||||
EcrireTexte(50, 300, "(Appuyez sur q pour quitter)", 1);
|
||||
|
||||
while(choix_image_fait == 0) {
|
||||
if(ToucheEnAttente()) {
|
||||
touche = Touche();
|
||||
|
||||
|
||||
if(touche == XK_1 || touche == XK_KP_1) {
|
||||
nom_image = "image1.png";
|
||||
choix_image_fait = 1;
|
||||
}
|
||||
else if(touche == XK_2 || touche == XK_KP_2) {
|
||||
nom_image = "image2.png";
|
||||
choix_image_fait = 2;
|
||||
}
|
||||
else if(touche == XK_3 || touche == XK_KP_3) {
|
||||
nom_image = "image3.png";
|
||||
choix_image_fait = 3;
|
||||
}
|
||||
else if(touche == XK_q || touche == XK_Q) {
|
||||
fermer_affichage();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
charger_image_source(nom_image);
|
||||
}
|
||||
}
|
||||
/*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; }
|
||||
|
||||
initialiser_plateau(grille);
|
||||
|
||||
melanger_plateau(grille);
|
||||
|
||||
afficher_plateau(grille);
|
||||
|
||||
while(jeu_fini == 0){
|
||||
|
||||
if (ToucheEnAttente()){
|
||||
touche = Touche();
|
||||
|
||||
/* Pour quitter on clique sur q */
|
||||
if (touche == XK_q || touche == XK_Q) break;
|
||||
|
||||
|
||||
/* Déplacement +on affiche la nouvelle grille */
|
||||
deplacer(grille, touche);
|
||||
afficher_plateau(grille);
|
||||
/*On vérifie si on a gagner */
|
||||
if(verifier_victoire(grille) == 1 ){
|
||||
jeu_fini = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (jeu_fini == 1){
|
||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||
RemplirRectangle(50,150,300,100);
|
||||
|
||||
ChoisirCouleurDessin(CouleurParNom("red"));
|
||||
EcrireTexte(60,200,"Bravo",2);
|
||||
EcrireTexte(60,230,"Appuyer pour quitter...",1);
|
||||
|
||||
Touche();
|
||||
}
|
||||
/*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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
FermerGraphique();
|
||||
init_affichage(ligne,colonne);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
charger_image_source(nom_image);
|
||||
|
||||
initialiser_plateau(grille,ligne,colonne);
|
||||
|
||||
melanger_plateau(grille,ligne,colonne);
|
||||
|
||||
afficher_plateau(grille,ligne,colonne,coups);
|
||||
|
||||
while(jeu_fini == 0){
|
||||
|
||||
if (ToucheEnAttente()){
|
||||
touche = Touche();
|
||||
|
||||
/* Pour quitter on clique sur q */
|
||||
if (touche == XK_q || touche == XK_Q) break;
|
||||
|
||||
|
||||
/* Déplacement +on affiche la nouvelle grille */
|
||||
deplacer(grille,ligne,colonne,touche);
|
||||
coups++;
|
||||
afficher_plateau(grille,ligne,colonne,coups);
|
||||
/*On vérifie si on a gagner */
|
||||
if(verifier_victoire(grille,ligne,colonne) == 1 ){
|
||||
jeu_fini = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (jeu_fini == 1){
|
||||
ChoisirCouleurDessin(CouleurParNom("white"));
|
||||
RemplirRectangle(50,150,300,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();
|
||||
|
||||
Reference in New Issue
Block a user