From 6b14cf17e8b0f87c8ad631684560ab1c7e9b4f5c Mon Sep 17 00:00:00 2001 From: boutarci Date: Thu, 21 Dec 2023 12:29:12 +0100 Subject: [PATCH] ajout menu mais non fonctionnel --- SAE_semestre1/fichier.h/main.h | 3 ++- SAE_semestre1/fichier.h/menu.h | 6 ++++- SAE_semestre1/fichier.h/serpent.h | 2 +- SAE_semestre1/img/tete_down.png | Bin 0 -> 4081 bytes SAE_semestre1/img/tete_left.png | Bin 0 -> 4095 bytes SAE_semestre1/img/tete_right.png | Bin 0 -> 4107 bytes SAE_semestre1/img/tete_up.png | Bin 0 -> 4098 bytes SAE_semestre1/src/main.c | 28 ++++++++++++++++++------ SAE_semestre1/src/menu.c | 35 +++++++++++++++--------------- SAE_semestre1/src/serpent.c | 11 +++++++--- SAE_semestre1/src/time.c | 2 +- 11 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 SAE_semestre1/img/tete_down.png create mode 100644 SAE_semestre1/img/tete_left.png create mode 100644 SAE_semestre1/img/tete_right.png create mode 100644 SAE_semestre1/img/tete_up.png diff --git a/SAE_semestre1/fichier.h/main.h b/SAE_semestre1/fichier.h/main.h index 39d1c80..0c85dc3 100755 --- a/SAE_semestre1/fichier.h/main.h +++ b/SAE_semestre1/fichier.h/main.h @@ -1,6 +1,7 @@ #ifndef MAIN_H #define MAIN_H - int main(void); +int jeu(void); +int main(void); #endif \ No newline at end of file diff --git a/SAE_semestre1/fichier.h/menu.h b/SAE_semestre1/fichier.h/menu.h index 132380e..716d75b 100755 --- a/SAE_semestre1/fichier.h/menu.h +++ b/SAE_semestre1/fichier.h/menu.h @@ -1,6 +1,10 @@ #ifndef MENU_H #define MENU_H -void menu(void); +typedef struct { + int x, y, L, H; +} zone; +int check_zone(zone z, int x, int y); +void afficher_menu(zone jouer, zone quitter, int *jeu); #endif \ No newline at end of file diff --git a/SAE_semestre1/fichier.h/serpent.h b/SAE_semestre1/fichier.h/serpent.h index 42094a5..a63307d 100755 --- a/SAE_semestre1/fichier.h/serpent.h +++ b/SAE_semestre1/fichier.h/serpent.h @@ -4,5 +4,5 @@ void Serpent(int pos_x[], int pos_y[], int old_x[], int old_y[], int *segment, int murx[], int mury[], int *go_on, int *direction); void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mury[], int *go_on); void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int*); -void Controle(int *direction, int last_direction, int *go_on); +void Controle(int *direction, int last_direction, int *go_on, int *pause); #endif diff --git a/SAE_semestre1/img/tete_down.png b/SAE_semestre1/img/tete_down.png new file mode 100644 index 0000000000000000000000000000000000000000..91f5e1d69128e8afb80ace8dd78fb885b9cfb301 GIT binary patch literal 4081 zcmeHKeM}Q)7(c8)MaXnWK!@{oYE<0yK3dxAjfy}KIxTj93JeF=ySH%C_R963g^6Q+ zO@=PfL=y>7mwl*UM+vM=2-S%RYTV_&%G;@-PLDVfPavi-+3?Y-~w z{+{3ayuasp-}LQpl@z5UO-n)$B*jr|FNNQ|otf46i@Pl2y#pu*vCI*}~c)+2Fo zPa-V;?nBO_%GM4o6)%}F}-f(^y>J$ySlSqoO4_*eEwlg zY5nBhQ;oUbU48k=N4kd>vdS*(8oy`Nj;)T_8>-hV(;vq+PufVf?>oDstz^pQcQb1S z?%w;&@LA8Xi+@@F+`jfavU_27?NM&BH0h$ZitTH=rk}q!>7Mo8`n>d6YkoX>>*uHX zww+nCYbteQXUjGHVOPKVgU-sYT^)Nn_}AZi;dpM}k<%@mJyi#Lez*NG@l3oA?7V3z z+Ikw>f#$bwX0!I4&hK8nWlHMQZ_^|!|z+~|8{#<$Hk$Ln)+E2=)OX&BeD`)vzbbxWUdCBbm$xvpc0)whw$ zb5_!`ijpq$F0dHq2)Y{N8O7PeJ0fuR~i zX|Q1xP8V7r$pAGOOa>A!42#V)wjc@3kp&N1YF{)+0ed#AUQq%pL4-mfL&#{5D^0F9EM9Gh;oSa)~QfwFo$I+qqd;zC3O79O2 zssQyM!d!r$3?$+65wRXYrLY;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sA1EJz}&H!ZwKTHJuaNw-DB8HN{e&X_^s6hi}!gsn{8J%-Be z3#gn=02&n}H%O3&rf8lwiX1Lx7%7|~c@xglJcpY|lS$+`i-of=V<^@r60AzjGuA7O zN`zEqUKCA$H{(1I%{XHgNIcU>Q8;Dds0@*zDBex#RHDGHloc-r(Y3`d+r{7aK89WdsQfp+0BczD6HkQg}(hcwfUok#c#<>C>p0I4SznUKDda!txL zAq6G`o~*7(xhAB*gus*4^}op#KYE=4KKL&v2ro;K%zN5ZD~4ZPU_%~gmoDRy7k-7W z$NYum0R)*kQ~O3B9i7Q=FjloY@?-m^#V01FRBhNl9}bn+Z8@&Y&xFcLy#rkl370#_ zJqcyW@WECkMy59(;KGwok6ViMBVzL?U;I>D7myoU3_(*z=2R$8xK;{R6#Aj^zLV literal 0 HcmV?d00001 diff --git a/SAE_semestre1/img/tete_right.png b/SAE_semestre1/img/tete_right.png new file mode 100644 index 0000000000000000000000000000000000000000..90f935e6b2bb45ad6f7c15c2e26e88005509b8ea GIT binary patch literal 4107 zcmeHKdrVVT7%x^!S0$05qbSb1t4_t;-bZg=cT|KHp=z}PDlimp?>&V(+TMD5p@oTa zKFIK~Op}>th>y%gXQs}8yq#q6bf=n^t?PB$k`UEI012qiOFNalasroHEU zkKg&e-}jx9o>t%7qBO%8gGQrC^Ax*F;Cqzv)$8Ez#@2CZ@HGaMdjejsCI^o7nv|3$ zHCi}IfgknBI9A^Yr)vb4%ja>qkccD(gdosp;%&{FoW&<+WOr1*@K#Az>estob+vTy znWLAzvtUZWTHmzyyOv77WYR)$Nmcf+uU4%dzkWe#X3gSpRm1XcXir_}@SHE4b-%i# zHvP)+WqIFUdg?n>>@&R;^f|KZ0%;*+Q(`dumSe+)-cN$gb|b zaq~~p7ww17{_VK?#;VUWJ7%;kJ;bJqBhLmana<|R`f0NbHyt@Kmd|mzz)>nMvYu(ezt=l*MNM7f`6OHTJEBCkGcK$W|5T>VwrkT-w(0w#PQL zZD><<@E$ipe|^aQme9-N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~& zL(7&1+`1~RV8i-`hK8x{44>*w8o|6#yk=iGXOvDiR<||gLZZ-M+gi5fz?=7O#58p^ nUOfG7-0PF9D}LJBP#l9@4U7U??#wr!1u$pMBFBNO170#6B literal 0 HcmV?d00001 diff --git a/SAE_semestre1/src/main.c b/SAE_semestre1/src/main.c index 7defba4..9dc3428 100644 --- a/SAE_semestre1/src/main.c +++ b/SAE_semestre1/src/main.c @@ -5,10 +5,12 @@ #include "../fichier.h/Oeuf.h" #include "../fichier.h/time.h" #include "../fichier.h/main.h" +#include "../fichier.h/menu.h" -#define CYCLE 10000L +#define CYCLE 100000L -int main(void){ +int lancer_jeu(){ + int pause = 1; int segment = 10; int go_on = 1; int direction = 4; @@ -34,23 +36,35 @@ int main(void){ unsigned long int *pointeur_suivant = &suivant; int *pointeur_seconde_actuel = &seconde_actuel; int *pointeur_old_seconde = &old_seconde; - InitialiserGraphique(); - CreerFenetre(350,100,1200,900); - EffacerEcran(CouleurParComposante(0,0,0)); + int *pointeur_pause = &pause; suivant = Microsecondes()+CYCLE; old_seconde=(suivant/1000000)%10; DessinerScene(murx, mury, minute, seconde ,timer); InitialiserOeufs(oeufx, oeufy, segment); Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, pointeur_go_on, pointeur_direction); while(go_on){ + Controle(pointeur_direction, 0, pointeur_go_on, pointeur_pause); + if(pause == 1){ Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer); - Score(segment); - Controle(pointeur_direction, 0, pointeur_go_on); Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction); Collision_Serpent(pos_x, pos_y, segment, murx, mury, pointeur_go_on); + Score(segment); usleep(100000); Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment); } + } +} +int main(void){ + int choix = 0; + InitialiserGraphique(); + CreerFenetre(350,100,1200,900); + EffacerEcran(CouleurParComposante(0,0,0)); + afficher_menu(&choix); + + while( choix == 1){ + lancer_jeu(); + } FermerGraphique(); return EXIT_SUCCESS; } + diff --git a/SAE_semestre1/src/menu.c b/SAE_semestre1/src/menu.c index 25d967b..5c7a832 100755 --- a/SAE_semestre1/src/menu.c +++ b/SAE_semestre1/src/menu.c @@ -1,25 +1,24 @@ #include #include +#include #include "../fichier.h/menu.h" - -int MenuDebut(){ - InitialiserGraphique(); - EcrireTexte(1000,760,"Score", 2); +int check_zone(zone z, int x, int y) { + return x >= z.x && x <= z.x + z.L && y >= z.y && y <= z.y + z.H; } -int menu(){ - while(menu){ - while(ToucheEnAttente()){ - t = Touche(); - switch(t3){ - case XK_q : - FermerGraphique(); - return EXIT_SUCCESS; - return; - case XK_Right : - menu = 0; - return + +void afficher_menu(zone jouer, zone quitter, int *choix) { + ChargerImageFond("../img/Menu.png"); + while(1){ + SourisPosition(); + + if(SourisCliquee()){ + int x = _X; + int y = _Y; + if (check_zone(jouer, _X, _Y)){ + *choix = 1; + return; } - } + } } -} \ No newline at end of file +} diff --git a/SAE_semestre1/src/serpent.c b/SAE_semestre1/src/serpent.c index 117bf06..d2f87d5 100755 --- a/SAE_semestre1/src/serpent.c +++ b/SAE_semestre1/src/serpent.c @@ -57,7 +57,7 @@ void Collision_Serpent(int pos_x[], int pos_y[], int segment, int murx[], int mu } } -void Controle(int *direction, int last_direction, int *go_on) { +void Controle(int *direction, int last_direction, int *go_on, int *pause) { int t; while(ToucheEnAttente()) { t = Touche(); @@ -86,8 +86,13 @@ void Controle(int *direction, int last_direction, int *go_on) { *direction = 0; *go_on = 0; return; - case XK_p: - *direction = 0; + case XK_space: + if (*pause == 0 ){ + *pause == 1; + }else{ + *pause = 0; + ChargerImage("../img/PAUSE.png", 400,200,0,0,350,300); + } } } } diff --git a/SAE_semestre1/src/time.c b/SAE_semestre1/src/time.c index 1a6b578..aa6fb39 100755 --- a/SAE_semestre1/src/time.c +++ b/SAE_semestre1/src/time.c @@ -4,7 +4,7 @@ #include "../fichier.h/time.h" #include "../fichier.h/main.h" #include "../fichier.h/serpent.h" -#define CYCLE 10000L +#define CYCLE 100000L void Score(int segment){ int nombre;