ajoute image plus menu simple

This commit is contained in:
2025-12-02 00:38:32 +01:00
parent aad348e2b8
commit 781217559e
10 changed files with 76 additions and 12 deletions
+34 -9
View File
@@ -10,23 +10,48 @@ void init_affichage(void){
/*La fenetre vass faire la taille de la grille*/
CreerFenetre(100, 100, NB_COLS * TAILLE_CASE, NB_LIGNES * TAILLE_CASE);
}
void charger_image_source(char *nom_fichier) {
ChoisirEcran(1);
EffacerEcran(CouleurParNom("black"));
/* On charge l'image. On force sa taille pour qu'elle remplisse bien le jeu */
ChargerImageFond(nom_fichier);
ChoisirEcran(0);
}
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]){
int i,j,x,y;
char texte[10];
EffacerEcran(CouleurParNom("white"));
int i,j;
int x_ecran, y_ecran;
int num_tuile;
int src_x, src_y;
EffacerEcran(CouleurParNom("black"));
for (i = 0; i < NB_LIGNES; i++){
for(j = 0; j < NB_COLS; j++){
/*Calcul en pixel de la taille d'une case*/
x = j * TAILLE_CASE;
y = i * TAILLE_CASE;
num_tuile = grille[i][j];
x_ecran = j * TAILLE_CASE;
y_ecran = i * TAILLE_CASE;
/*Ici on saute la case vide du taquin*/
if (grille[i][j] == 0) continue;
if (num_tuile == 0) {
ChoisirCouleurDessin(CouleurParNom("black"));
RemplirRectangle(x_ecran, y_ecran, TAILLE_CASE, TAILLE_CASE);
continue;
}
src_x = ((num_tuile - 1) % NB_COLS) * TAILLE_CASE;
src_y = ((num_tuile - 1) / NB_COLS) * TAILLE_CASE;
CopierZone(1, 0, src_x, src_y, TAILLE_CASE, TAILLE_CASE, x_ecran, y_ecran);
/*ET on ecrit le numéro dans un rectagle*/
ChoisirCouleurDessin(CouleurParNom("black"));
DessinerRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
sprintf(texte, "%d", grille[i][j]);
EcrireTexte(x + 40, y + 60, texte, 2);
DessinerRectangle(x_ecran, y_ecran, TAILLE_CASE, TAILLE_CASE);
}
}
}