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:
2025-12-04 00:21:45 +01:00
parent 7325bc7500
commit 20ec920174
8 changed files with 227 additions and 131 deletions
+23 -16
View File
@@ -4,11 +4,11 @@
#include "config.h"
void init_affichage(void){
void init_affichage(int nb_ligne,int nb_colonne){
InitialiserGraphique();
/*La fenetre vass faire la taille de la grille*/
CreerFenetre(100, 100, NB_COLS * TAILLE_CASE, NB_LIGNES * TAILLE_CASE);
CreerFenetre(100, 100, nb_colonne * TAILLE_CASE, (nb_ligne * TAILLE_CASE)+60);
}
void charger_image_source(char *nom_fichier) {
@@ -22,36 +22,43 @@ void charger_image_source(char *nom_fichier) {
ChoisirEcran(0);
}
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]){
void afficher_plateau(int grille[MAX_TAILLE][MAX_TAILLE],int nb_ligne,int nb_colonne,int coups){
int i,j;
int x_ecran, y_ecran;
int num_tuile;
int x, y;
int num;
int src_x, src_y;
char text_coups[50];
EffacerEcran(CouleurParNom("black"));
/*Compteur de coups*/
ChoisirCouleurDessin(CouleurParNom("white"));
sprintf(text_coups,"Coups : %d",coups);
/*Comme la taille de l'écran chage y n'est pas fixe*/
EcrireTexte(10,nb_ligne*TAILLE_CASE + 40, text_coups,2);
for (i = 0; i < NB_LIGNES; i++){
for(j = 0; j < NB_COLS; j++){
for (i = 0; i < nb_ligne; i++){
for(j = 0; j < nb_colonne; j++){
/*Calcul en pixel de la taille d'une case*/
num_tuile = grille[i][j];
x_ecran = j * TAILLE_CASE;
y_ecran = i * TAILLE_CASE;
num = grille[i][j];
x = j * TAILLE_CASE;
y = i * TAILLE_CASE;
/*Ici on saute la case vide du taquin*/
if (num_tuile == 0) {
if (num == 0) {
ChoisirCouleurDessin(CouleurParNom("black"));
RemplirRectangle(x_ecran, y_ecran, TAILLE_CASE, TAILLE_CASE);
RemplirRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
continue;
}
src_x = ((num_tuile - 1) % NB_COLS) * TAILLE_CASE;
src_y = ((num_tuile - 1) / NB_COLS) * TAILLE_CASE;
src_x = ((num - 1) % nb_colonne) * TAILLE_CASE;
src_y = ((num - 1) / nb_colonne) * TAILLE_CASE;
CopierZone(1, 0, src_x, src_y, TAILLE_CASE, TAILLE_CASE, x_ecran, y_ecran);
CopierZone(1, 0, src_x, src_y, TAILLE_CASE, TAILLE_CASE, x, y);
/*ET on ecrit le numéro dans un rectagle*/
ChoisirCouleurDessin(CouleurParNom("black"));
DessinerRectangle(x_ecran, y_ecran, TAILLE_CASE, TAILLE_CASE);
DessinerRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
}
}
}