ajoute image plus menu simple
This commit is contained in:
+34
-9
@@ -10,23 +10,48 @@ void init_affichage(void){
|
|||||||
/*La fenetre vass faire la taille de la grille*/
|
/*La fenetre vass faire la taille de la grille*/
|
||||||
CreerFenetre(100, 100, NB_COLS * TAILLE_CASE, NB_LIGNES * TAILLE_CASE);
|
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]){
|
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]){
|
||||||
int i,j,x,y;
|
int i,j;
|
||||||
char texte[10];
|
int x_ecran, y_ecran;
|
||||||
EffacerEcran(CouleurParNom("white"));
|
int num_tuile;
|
||||||
|
int src_x, src_y;
|
||||||
|
|
||||||
|
EffacerEcran(CouleurParNom("black"));
|
||||||
|
|
||||||
for (i = 0; i < NB_LIGNES; i++){
|
for (i = 0; i < NB_LIGNES; i++){
|
||||||
for(j = 0; j < NB_COLS; j++){
|
for(j = 0; j < NB_COLS; j++){
|
||||||
/*Calcul en pixel de la taille d'une case*/
|
/*Calcul en pixel de la taille d'une case*/
|
||||||
x = j * TAILLE_CASE;
|
num_tuile = grille[i][j];
|
||||||
y = i * TAILLE_CASE;
|
x_ecran = j * TAILLE_CASE;
|
||||||
|
y_ecran = i * TAILLE_CASE;
|
||||||
/*Ici on saute la case vide du taquin*/
|
/*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*/
|
/*ET on ecrit le numéro dans un rectagle*/
|
||||||
ChoisirCouleurDessin(CouleurParNom("black"));
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||||
DessinerRectangle(x, y, TAILLE_CASE, TAILLE_CASE);
|
DessinerRectangle(x_ecran, y_ecran, TAILLE_CASE, TAILLE_CASE);
|
||||||
sprintf(texte, "%d", grille[i][j]);
|
|
||||||
EcrireTexte(x + 40, y + 60, texte, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
void init_affichage(void);
|
void init_affichage(void);
|
||||||
void fermer_affichage(void);
|
void fermer_affichage(void);
|
||||||
|
void charger_image_source(char *nom_fichier);
|
||||||
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]);
|
void afficher_plateau(int grille[NB_LIGNES][NB_COLS]);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 110 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 208 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 207 KiB |
@@ -7,9 +7,48 @@
|
|||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
int grille[NB_LIGNES][NB_COLS], touche;
|
int grille[NB_LIGNES][NB_COLS], touche;
|
||||||
|
char *nom_image = NULL;
|
||||||
init_affichage();
|
int choix_fait = 0;
|
||||||
|
|
||||||
|
init_affichage();
|
||||||
|
|
||||||
|
EffacerEcran(CouleurParNom("white"));
|
||||||
|
ChoisirCouleurDessin(CouleurParNom("black"));
|
||||||
|
|
||||||
|
EcrireTexte(50, 50, "MENU TAQUIN", 2);
|
||||||
|
EcrireTexte(50, 100, "Choisissez votre image :", 1);
|
||||||
|
EcrireTexte(50, 150, "Touche 1 : Image 1", 1);
|
||||||
|
EcrireTexte(50, 180, "Touche 2 : Image 2", 1);
|
||||||
|
EcrireTexte(50, 210, "Touche 3 : Image 3", 1);
|
||||||
|
EcrireTexte(50, 300, "(Appuyez sur q pour quitter)", 1);
|
||||||
|
|
||||||
|
while(choix_fait == 0) {
|
||||||
|
if(ToucheEnAttente()) {
|
||||||
|
touche = Touche();
|
||||||
|
|
||||||
|
printf("Touche reçue : %d (Caractère : %c)\n", touche, (char)touche);
|
||||||
|
|
||||||
|
if(touche == '1' || touche == 38) {
|
||||||
|
nom_image = "image1.png";
|
||||||
|
choix_fait = 1;
|
||||||
|
}
|
||||||
|
else if(touche == '2' || touche == 233) {
|
||||||
|
nom_image = "image2.png";
|
||||||
|
choix_fait = 2;
|
||||||
|
}
|
||||||
|
else if(touche == '3' || touche == 34) {
|
||||||
|
nom_image = "image3.png";
|
||||||
|
choix_fait = 3;
|
||||||
|
}
|
||||||
|
else if(touche == 'q' || touche == 27) {
|
||||||
|
fermer_affichage();
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
charger_image_source(nom_image);
|
||||||
|
|
||||||
initialiser_plateau(grille);
|
initialiser_plateau(grille);
|
||||||
|
|
||||||
melanger_plateau(grille);
|
melanger_plateau(grille);
|
||||||
|
|||||||
Reference in New Issue
Block a user