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
|
|
|
|
|
|
|
|
void init_affichage(void){
|
|
|
|
|
|
|
|
|
|
InitialiserGraphique();
|
2025-11-30 16:16:27 +01:00
|
|
|
/*La fenetre vass faire la taille de la grille*/
|
|
|
|
|
CreerFenetre(100, 100, NB_COLS * TAILLE_CASE, NB_LIGNES * TAILLE_CASE);
|
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-11-30 16:16:27 +01:00
|
|
|
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]){
|
2025-12-02 00:38:32 +01:00
|
|
|
int i,j;
|
|
|
|
|
int x_ecran, y_ecran;
|
|
|
|
|
int num_tuile;
|
|
|
|
|
int src_x, src_y;
|
|
|
|
|
|
|
|
|
|
EffacerEcran(CouleurParNom("black"));
|
2025-11-29 20:25:05 +01:00
|
|
|
|
2025-11-30 16:16:27 +01:00
|
|
|
for (i = 0; i < NB_LIGNES; i++){
|
|
|
|
|
for(j = 0; j < NB_COLS; j++){
|
|
|
|
|
/*Calcul en pixel de la taille d'une case*/
|
2025-12-02 00:38:32 +01:00
|
|
|
num_tuile = grille[i][j];
|
|
|
|
|
x_ecran = j * TAILLE_CASE;
|
|
|
|
|
y_ecran = 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
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2025-11-30 16:16:27 +01:00
|
|
|
/*ET on ecrit le numéro dans un rectagle*/
|
|
|
|
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
2025-12-02 00:38:32 +01:00
|
|
|
DessinerRectangle(x_ecran, y_ecran, 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
|
|
|
}
|