suppression de la constante TAILLE_CASE pour que lecran sadapte a limage directement pour pas faire de probleme de dimension en ajoutant des variable de types int img_w et image_h ainsi que hauteur_image et largeur_img qui sont representer par l_case et h_case (je l'ai appeler img_w car ça peut porter a confusion en francais vu quil y a longueu et largeur donc jai choisi w pour width et pas img_l). Ainsi quune correction dans affichage.c : j'ai retire -1 dans les lignes avec src_x et src_y car sinon il y a un decalage donc comme ca le num 1 correspond bien au morceau dimage 1

This commit is contained in:
2025-12-05 21:17:40 +01:00
parent a3ae70648b
commit 1ca9ee8f1d
5 changed files with 35 additions and 23 deletions
+19 -8
View File
@@ -9,6 +9,10 @@ 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;
@@ -46,14 +50,17 @@ int main(void){
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 = 400; img_h = 400;
choix_image_fait = 2;
}
else if(touche == XK_3 || touche == XK_KP_3) {
nom_image = "image3.png";
img_w = 400; img_h = 400;
choix_image_fait = 3;
}
else if(touche == XK_q || touche == XK_Q) {
@@ -130,13 +137,16 @@ int main(void){
}
}
/* CALCUL AUTO des tailles*/
l_case = img_w / colonne;
h_case = img_h / ligne;
FermerGraphique();
init_affichage(ligne,colonne);
/* On met la taille de l'image pour créer la fenêtre */
init_affichage(img_w, img_h);
charger_image_source(nom_image);
@@ -144,7 +154,7 @@ int main(void){
melanger_plateau(grille,ligne,colonne);
afficher_plateau(grille,ligne,colonne,coups);
afficher_plateau(grille,ligne,colonne,coups, l_case, h_case);
while(jeu_fini == 0){
@@ -160,7 +170,7 @@ int main(void){
/* Déplacement +on affiche la nouvelle grille */
if (deplacer(grille,ligne,colonne,touche) == 1) {
coups++;
afficher_plateau(grille,ligne,colonne,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;
@@ -171,7 +181,8 @@ int main(void){
if (jeu_fini == 1){
ChoisirCouleurDessin(CouleurParNom("white"));
RemplirRectangle(50,150,300,100);
/* 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);