From 9c4cf607299c2afc5995c08555c14ddf1f4bc33b Mon Sep 17 00:00:00 2001 From: brigitte Date: Tue, 19 Dec 2023 13:09:01 +0100 Subject: [PATCH] enlevement extern 5 --- JEUX_SERPENT/Jeux | Bin 21968 -> 21976 bytes JEUX_SERPENT/fonction.h | 12 ++++++------ JEUX_SERPENT/main.c | 16 +++++++++------- JEUX_SERPENT/scene.c | 2 +- JEUX_SERPENT/score.c | 2 +- JEUX_SERPENT/serpent.c | 23 ++++++++++++++++------- 6 files changed, 33 insertions(+), 22 deletions(-) diff --git a/JEUX_SERPENT/Jeux b/JEUX_SERPENT/Jeux index c07a3bb1351e1a25e46e779eedee8dc1c4476742..afe109d74c6f505dc6d4fa4d341c7f8e9b9392ad 100755 GIT binary patch delta 4641 zcmZu#3v^V)8NPRu0TPoel8>?Qum#lY_4+Lehdp1$^;&-Pm3y!l*8hVa=lECYL_Feoo}+8 zNnEw;;GxvM6->LqwmpAk`!avl+UGjjBR-AO*Yj2Jg_-@jruo^~S#nZaCrQ(P*|J)C z+%FpJbKV<2BkDBNE`yzz#cMN5JR31GSSebsU-BP;k&`~mG}t@=n+L`~%Vx-V`6Rr4 zbK^LY>}m`RHbxRNqKJ5@n4qx|YQu!eDh6we;9qaxBY|v?Yk} zV1ev=Jj0gdWx0oldL7#4K%M(4KP$#8dQ=Egz(NS$HP}>P&TY!+S-?f__BX0r-s1*a z1NE#Yv4H0)gFTEvb0EPJ?Pq3@v}dp*wE|onYp_G;dS>mkY1(Q~-c*z}Y0K3-l<936 z@;d`G)9)N6VI=i~1tVxnyuIH2u2yz2mA32aLYy@W--imjm;PmcV_Ewsp}HPJ(~bCO z<`G~No*9sPcY3h;K61D#kr>pNpMQ;67J6OObW>yQQnPfLg*mj;Jz^p>& z1{AK1uGYjB7$M)s*6_NFFb6L2;pDkd2j7R)7@N7CmpMu%{y~lm zXW$C=*79wRs(|zf~6Fq{Ta+ayf&S@#TvnVRDiN zm-c!J(<$<;W0dxjWT_nq@p`@^W!k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Jvv`HP~ZuZ(s$_Kwg5(g8ULWUtrUMwLBcrbx@Q- z?&0T?67(rtPj={`JUTfsJ`CY>1FDS(4qa;-*`3ez7sQ!9+S?;LW zdQ7Qu*bgU;p59mkIo#fpf15Eq`YjcQNI2k^0f%YPS`(j|IXYlycVVNw$v?|X)Nk^J z%omfA;fNe0#!2k56xvQ@d11U%V8_I>pX*MCewdFK?FcxkIL$nFv?I(^Ok5-J94BVd z8NrFtwzczf0s2rxR^pvdS$)TooQ~-0%4$zLpQYq8`nIr*(yA4zOtlu?FxsJa;J2I( zR|3{WEAKQxqTZ;UR_hIpm-^o;Yo?6p8+89zVvRFQa}+k+K>SF1?A%h3%m3nWxQSn2|++)75b #include "fonction.h" -void Score(){ +void Score(int segment){ Nbr=(segment-10)*10; snprintf(score,5,"%04d", Nbr); ChoisirCouleurDessin(CouleurParComposante(0,0,0)); diff --git a/JEUX_SERPENT/serpent.c b/JEUX_SERPENT/serpent.c index 9ccd1fa..7c1133c 100644 --- a/JEUX_SERPENT/serpent.c +++ b/JEUX_SERPENT/serpent.c @@ -48,7 +48,7 @@ int Controle(int direction){ } /*Avancement automatique du serpent en fonction de la direction*/ -void Serpent(int direction){ +void Serpent(int direction, int segment){ if (direction == 1){ pos_y[0]=old_y[0]-20; } @@ -61,7 +61,7 @@ void Serpent(int direction){ if (direction == 4){ pos_x[0]=old_x[0]+20; } - Update_Serpent(direction); + Update_Serpent(direction, segment); Terrain(); } @@ -70,9 +70,6 @@ long int Update_Vitesse(long int vitesse){ int p=0; for(p=0; p<5; p++){ if(pommex[p]==pos_x[0] && pommey[p]==pos_y[0]){ - segment+=2; - pommex[p] = ((rand() % (58)+1)*20); - pommey[p] = ((rand() % (34)+1)*20); if (vitesse>20000){ vitesse=vitesse-1500; printf("%ld\n", vitesse); @@ -82,8 +79,20 @@ long int Update_Vitesse(long int vitesse){ return vitesse; } +int Update_Segment(int segment){ + int p=0; + for(p=0; p<5; p++){ + if(pommex[p]==pos_x[0] && pommey[p]==pos_y[0]){ + segment=segment+2; + pommex[p] = ((rand() % (58)+1)*20); + pommey[p] = ((rand() % (34)+1)*20); + } + } + return segment; +} + /*fonction pour mettre à jour la position du serpent*/ -void Update_Serpent(int direction){ +void Update_Serpent(int direction, int segment){ int i=1; AfficherSprite(fond, pos_x[segment-1], pos_y[segment-1]); /*affichage de la tete en fonction de la direction du serpent*/ @@ -120,7 +129,7 @@ void Update_Serpent(int direction){ } /*Fonction pour détécter si le serpent se touche lui même*/ -void Collision(){ +void Collision(int segment){ int i=1; if(seconde!=0 || minute!=0){ for(i=1; i