2025-11-30 16:16:27 +01:00
|
|
|
#include <stdio.h>
|
2025-11-29 20:25:05 +01:00
|
|
|
#include "affichage.h"
|
|
|
|
|
#include <graph.h>
|
2025-11-30 16:16:27 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2025-11-29 20:25:05 +01:00
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
void init_affichage(int nb_ligne,int nb_colonne){
|
2025-11-29 20:25:05 +01:00
|
|
|
|
|
|
|
|
InitialiserGraphique();
|
2025-11-30 16:16:27 +01:00
|
|
|
/*La fenetre vass faire la taille de la grille*/
|
2025-12-04 00:21:45 +01:00
|
|
|
CreerFenetre(100, 100, nb_colonne * TAILLE_CASE, (nb_ligne * TAILLE_CASE)+60);
|
2025-11-29 20:25:05 +01:00
|
|
|
}
|
2025-12-02 00:38:32 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
void afficher_plateau(int grille[MAX_TAILLE][MAX_TAILLE],int nb_ligne,int nb_colonne,int coups){
|
2025-12-02 00:38:32 +01:00
|
|
|
int i,j;
|
2025-12-04 00:21:45 +01:00
|
|
|
int x, y;
|
|
|
|
|
int num;
|
2025-12-02 00:38:32 +01:00
|
|
|
int src_x, src_y;
|
2025-12-04 00:21:45 +01:00
|
|
|
char text_coups[50];
|
2025-12-02 00:38:32 +01:00
|
|
|
|
|
|
|
|
EffacerEcran(CouleurParNom("black"));
|
2025-12-04 00:21:45 +01:00
|
|
|
/*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);
|
|
|
|
|
|
2025-11-29 20:25:05 +01:00
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
for (i = 0; i < nb_ligne; i++){
|
|
|
|
|
for(j = 0; j < nb_colonne; j++){
|
2025-11-30 16:16:27 +01:00
|
|
|
/*Calcul en pixel de la taille d'une case*/
|
2025-12-04 00:21:45 +01:00
|
|
|
num = grille[i][j];
|
|
|
|
|
x = j * TAILLE_CASE;
|
|
|
|
|
y = i * TAILLE_CASE;
|
2025-11-30 16:16:27 +01:00
|
|
|
/*Ici on saute la case vide du taquin*/
|
2025-12-02 00:38:32 +01:00
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
if (num == 0) {
|
2025-12-02 00:38:32 +01:00
|
|
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
2025-12-04 00:21:45 +01:00
|
|
|
RemplirRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
|
2025-12-02 00:38:32 +01:00
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
src_x = ((num - 1) % nb_colonne) * TAILLE_CASE;
|
|
|
|
|
src_y = ((num - 1) / nb_colonne) * TAILLE_CASE;
|
2025-12-02 00:38:32 +01:00
|
|
|
|
2025-12-04 00:21:45 +01:00
|
|
|
CopierZone(1, 0, src_x, src_y, TAILLE_CASE, TAILLE_CASE, x, y);
|
2025-12-02 00:38:32 +01:00
|
|
|
|
2025-11-30 16:16:27 +01:00
|
|
|
/*ET on ecrit le numéro dans un rectagle*/
|
|
|
|
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
2025-12-04 00:21:45 +01:00
|
|
|
DessinerRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
|
2025-11-30 16:16:27 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-11-29 20:25:05 +01:00
|
|
|
void fermer_affichage(void){
|
2025-11-30 16:16:27 +01:00
|
|
|
FermerGraphique();
|
2025-11-29 20:25:05 +01:00
|
|
|
}
|