1
0

Séparation du menu en deux fichiers et création d'un dossier dédié au fichiers sources

This commit is contained in:
Lyanis SOUIDI 2022-11-23 17:05:57 +01:00
parent 495bf28cad
commit 5dbe011263
2 changed files with 44 additions and 46 deletions

37
src/main.c Normal file
View File

@ -0,0 +1,37 @@
#include<stdio.h>
#include<stdlib.h>
#include<graph.h>
#include"../include/menu.h"
typedef struct {
int x, y, L, H;
} Zone;
/*Check si une position (x,y) se trouve dans la zone; retourne 1 si dedans, sinon 0.*/
int checkzone(Zone z, int x, int y) {
return x >= z.x && x <= z.x + z.L && y >= z.y && y <= z.y + z.H;
}
void dessinerbouton(Zone z, char* texte, couleur arriereplan, couleur bordure, couleur couleurtexte, int tailletexte) {
ChoisirCouleurDessin(arriereplan);
RemplirRectangle(z.x, z.y, z.L, z.H);
ChoisirCouleurDessin(bordure);
DessinerRectangle(z.x, z.y, z.L, z.H);
ChoisirCouleurDessin(couleurtexte);
EcrireTexte(z.x + z.L / 2 - TailleChaineEcran(texte, tailletexte) / 2, z.y + z.H / 2 + TailleSupPolice(tailletexte) / 2, texte, tailletexte);
}
void dessinerzone(Zone z) {
RemplirRectangle(z.x, z.y, z.L, z.H);
}
int main(void){
InitialiserGraphique();
CreerFenetre(375,175,1250,750);
menu();
FermerGraphique();
return EXIT_SUCCESS;
}

View File

@ -1,40 +1,9 @@
#include<stdio.h>
#include<stdlib.h>
#include<graph.h>
#include"../include/main.h"
typedef struct {
int x,y,L,H;
} Zone;
/*Check si une position (x,y) se trouve dans la zone; retourne 1 si dedans, sinon 0.*/
int checkzone(Zone z, int x, int y) {
return x >= z.x && x <= z.x + z.L && y >= z.y && y <= z.y + z.H;
}
void dessinerbouton(Zone z, char* texte, couleur arriereplan, couleur bordure, couleur couleurtexte, int tailletexte) {
ChoisirCouleurDessin(arriereplan);
RemplirRectangle(z.x, z.y, z.L, z.H);
ChoisirCouleurDessin(bordure);
DessinerRectangle(z.x, z.y, z.L, z.H);
ChoisirCouleurDessin(couleurtexte);
EcrireTexte(z.x + z.L / 2 - TailleChaineEcran(texte, tailletexte) / 2,
z.y + z.H / 2 + TailleSupPolice(tailletexte) / 2,
texte, tailletexte);
}
void dessinerzone(Zone z) {
RemplirRectangle(z.x, z.y, z.L, z.H);
}
int main()
{
int boucle = 1;
void menu(void) {
Zone Titre = {490, 60, 260, 55};
Zone Selection = {42, 300, 230, 35};
Zone Facile = {42, 375, 85, 35};
@ -42,9 +11,6 @@ int main()
Zone Difficile = {42, 525, 85, 35};
Zone Quitter = {42, 605, 100, 35};
InitialiserGraphique();
CreerFenetre(375,175,1250,750);
ChargerImageFond("./img/backgrounds/menu.png");
dessinerbouton(Titre, "JEU DE PAIRES !", CouleurParNom("black"), CouleurParNom("white"), CouleurParNom("white"), 2);
@ -60,17 +26,12 @@ int main()
dessinerbouton(Quitter, "QUITTER", CouleurParNom("red"), CouleurParNom("red"), CouleurParNom("white"), 1);
while(boucle) {
int boucle = 1;
while (boucle) {
SourisPosition();
if(SourisCliquee()){
if(checkzone(Quitter, _X, _Y))
boucle = 0;
if (SourisCliquee()) {
if (checkzone(Quitter, _X, _Y)) boucle = 0;
}
}
FermerGraphique();
return EXIT_SUCCESS;
}
}