From 759f65984e71a7c56bf3b08e09ae861263829fef Mon Sep 17 00:00:00 2001 From: brigitte Date: Thu, 21 Dec 2023 11:33:41 +0100 Subject: [PATCH] enlevement extern 6 --- JEUX_SERPENT/Jeux | Bin 22160 -> 22192 bytes JEUX_SERPENT/fonction.h | 3 +-- JEUX_SERPENT/main.c | 8 ++++---- JEUX_SERPENT/scene.c | 19 ++----------------- JEUX_SERPENT/serpent.c | 8 +++----- JEUX_SERPENT/timer.c | 19 ++++++++++++++++++- 6 files changed, 28 insertions(+), 29 deletions(-) diff --git a/JEUX_SERPENT/Jeux b/JEUX_SERPENT/Jeux index d95008ecf65453da0fd375b4ecd37df6f9c8c108..535aff10b4b2bd6378ebfe2f0c8dc28eadd7cd23 100755 GIT binary patch delta 5262 zcmZu#4OCQR8oqaiF9AV77-j}heiSXu1jCdRjc|0(N(=F?wZgEpj#wF4`E%VkxQ#bE zV(XjoX?dEEY+879J;$iYN)wXC=Hq9xHe9Kgz$vEzZ(qfu6feTEgMC zX4$XzYxy?%%=sBBN{6n@YdG7_U2R?(BX8%C@i}rKpB#VhU8=?Vr6j4*7pP^nTuE|$ z;qrK=m?UW*v3e`6Ynqd7T_;OU7uyOgr^?>uHSrS_r^}*Ekfe*lWis7?Aq?NW1s(ef zCeW**4#IE3sb?-sRkl)BoD@Ndr6jUs3+D?7_!{b8#}Jevgb(W4(?P4UahR0*Y!?(x=RGFfFG!&J@Pjdrpc z{a4XhHj*s*RcbA3s2$S?8TZg!_@@)RHYAC%a6pWmKCJKwh=FdZ%6nln-3u- zDNKY=36Mfq8BN$zm{rurR5aeuG-Rb~Rs(9!){DO6H%)V~VS+aeZMpB+vc4WR8g}$m zl9nQQ%}}eTFZ*0&0|jH5S2ynqxfmTkT;z1Ms_bRJxvygDD1BA76q9mayb|eQXYUq# z2ssCID)YG#imrOt`ja}r#s1g?9;R?P zF?sUO*RW-f>_qhHnAgCdvRBaVPk{0PY5>*{$exC{yk2&(g+l8w|8x#7PK;N!7({Kq z644l;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ni?#sLsD-IasKp|xrXN;u5Po**H70k0T4zbGp>o+u_*YUs#^ zPRa<9p1Om)T52|f1UeTAprzcrW&;Ny2Cyhyb0#tfxUHzd|{c0-_ZaP#MBn&IpZkVZ_dKCvAJUd0E zJ+O-4oBDWrQflOxKI5I}<64qEzWp4X+V?ZznC*KK6IeC{VHsO_R&s)AT_y!~E(fA# zHZ1U|d4!t$FY^t_<2`sy;RYu;QejtqMcU(wjn(#)D>gI0&=mVXQ^I7Nfeci0-Y*Ha zl1&is)lvX9H7`mCPx-Fil{*Jt#T2XCw<@5&Iy%HipS7c>raK%5t;dO9-yo?0iVm3p z8PAMj+Xl13UPh1S%_CmSccb+SYkWo20ULPV>U)3rD0{xuH_Z=he=@u`zJ(8~rUP`} zDIxV?nxsJ+^661#OnQMPfk|&x`dkre=(oobz=KsxMiGtg%>=<7+!Ex^jVuWNr&tPl; z7R+I09Hb`ry{>2?}TGIj;SDeu_2X606kkcR^RW)q^ zlFF&Pe=?E_skF=7QfWKV)g?I2-Iq4}8$g+%1T+wLjGp5&q zFon(KlVblK&fXE@ zP0%@22DOmKgxTeY`qJX@GJo1NS-!ycxa`iW$TLQAO81}Dc{q2Xh4a%cyF7}opJUIC zN7fXj!-y{S0jz5cdvA(9N7M>x4lgRP%Qw+nxr9GfV&`ooVJ`BpaIDTeqYJ4V9w>U$ zT-^|iewSfi6q3~veyqgqe87m?o}|xmVodGNT%Kch));fcLws)F*~sTbk<~7~7|eM% zPn6ZNRDHhKOQ^ev<7_eftPIKFAfctl4YV!F1BU #include -extern int seconde, minute, seconde_actuel, old_seconde; extern char timer[6]; extern int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400]; @@ -26,7 +25,7 @@ int Update_Segment(int segment); void Terrain(); -void Timer(unsigned long int suivant); +void Timer(unsigned long int suivant, unsigned long int old_seconde); void Update_Timer(); void DessinerScene(int segment, int serpent, int pomme); int Score(int segment, int Nbr); diff --git a/JEUX_SERPENT/main.c b/JEUX_SERPENT/main.c index a4cc087..b1f69a3 100644 --- a/JEUX_SERPENT/main.c +++ b/JEUX_SERPENT/main.c @@ -2,9 +2,9 @@ #include #include #include "fonction.h" -#define CYCLE 10000L +#define CYCLE 100000L -int seconde=0, minute=0, seconde_actuel, old_seconde; +unsigned long int old_seconde; char timer[6]; int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400]; @@ -64,9 +64,9 @@ int main(){ /*creation de la scene du jeu*/ EffacerEcran(CouleurParComposante(0,0,0)); + DessinerScene(segment, serpent, pomme); suivant=Microsecondes()+CYCLE; old_seconde=(suivant/1000000)%10; - DessinerScene(segment, serpent, pomme); /*Boucle Principale du Programme*/ while(go_on){ @@ -77,7 +77,7 @@ int main(){ Controle(direction); if (pause==1){ - Timer(suivant); + Timer(suivant, old_seconde); Collision(segment); Update_Vitesse(vitesse); Update_Segment(segment); diff --git a/JEUX_SERPENT/scene.c b/JEUX_SERPENT/scene.c index e77be2f..bddbf85 100644 --- a/JEUX_SERPENT/scene.c +++ b/JEUX_SERPENT/scene.c @@ -2,7 +2,7 @@ #include #include #include "fonction.h" -#define LIGNE 40 +#define LIGNE 34 #define COLONNE 58 #define TAILLE_CASE 20 @@ -37,7 +37,7 @@ void DessinerScene(int segment, int serpent, int pomme){ posx = TAILLE_CASE; } - snprintf(timer,6,"%02d:%02d", minute, seconde); + snprintf(timer,6,"%02d:%02d", 0, 0); ChoisirCouleurDessin(CouleurParComposante(255,255,255)); EcrireTexte(10,760,timer,2); @@ -66,21 +66,6 @@ void MenuDebut(){ EcrireTexte(290,400,"Appuyer sur Fleche de Droite pour lancer le jeu",2); } -/*création du Menu de Fin*/ -void MenuDeFin(int Nbr){ - EffacerEcran(CouleurParComposante(0,0,0)); - imageMenu=ChargerSprite("IMG/menu1.png"); - AfficherSprite(imageMenu,0,0); - ChoisirCouleurDessin(CouleurParComposante(0,0,0)); - EcrireTexte(500,100,"Game Over", 2); - snprintf(score,15,"Score : %04d", Nbr); - EcrireTexte(500,200,score,2); - snprintf(timer,14,"Temps : %02d:%02d", minute, seconde); - EcrireTexte(490,300,timer,2); - EcrireTexte(410,500,"Appuyer sur Q pour quitter",2); - /*EcrireTexte(350,600,"Appuyer sur R pour relancer une partie",2);*/ -} - /*Apparition aléatoire des pommes*/ void Pomme(int pomme){ for (pp = 0; pp < 5; ++pp) { diff --git a/JEUX_SERPENT/serpent.c b/JEUX_SERPENT/serpent.c index f4f749e..7e77ef1 100644 --- a/JEUX_SERPENT/serpent.c +++ b/JEUX_SERPENT/serpent.c @@ -131,11 +131,9 @@ void Update_Serpent(int direction, int segment, int tete_up, int tete_down, int /*Fonction pour détécter si le serpent se touche lui même*/ void Collision(int segment){ int i=1; - if(seconde!=0 || minute!=0){ - for(i=1; i suivant){ suivant = Microsecondes()+CYCLE; seconde_actuel = (suivant/1000000)%10; @@ -38,4 +41,18 @@ void Attendre(long int microsecondes){ attendre = Microsecondes()+ microsecondes; while (Microsecondes() < attendre){ } +} + +/*création du Menu de Fin*/ +void MenuDeFin(int Nbr){ + EffacerEcran(CouleurParComposante(0,0,0)); + imageMenuFin=ChargerSprite("IMG/menu1.png"); + AfficherSprite(imageMenuFin,0,0); + ChoisirCouleurDessin(CouleurParComposante(0,0,0)); + EcrireTexte(500,100,"Game Over", 2); + snprintf(score,15,"Score : %04d", Nbr); + EcrireTexte(500,200,score,2); + snprintf(timer,14,"Temps : %02d:%02d", minute, seconde); + EcrireTexte(490,300,timer,2); + EcrireTexte(410,500,"Appuyer sur Q pour quitter",2); } \ No newline at end of file