From 8f26f7027d5b8ad2616277f2909d4e44b055f9f7 Mon Sep 17 00:00:00 2001 From: boutarci Date: Wed, 20 Dec 2023 21:26:34 +0100 Subject: [PATCH] =?UTF-8?q?changement=20de=20d=C3=A9cors,=20rajout=20oeuf,?= =?UTF-8?q?=20s=C3=A9parations=20de=20tout=20les=20fichiers=20+=20erreurs?= =?UTF-8?q?=20MAKE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SAE_semestre1/fichier.h/Oeuf.h | 7 +++ SAE_semestre1/fichier.h/pastille.h | 7 --- SAE_semestre1/fichier.h/serpent.h | 2 +- SAE_semestre1/fichier.h/terrain.h | 2 +- SAE_semestre1/fichier.h/time.h | 2 + SAE_semestre1/img/cactus.png | Bin 0 -> 5052 bytes SAE_semestre1/img/fond.png | Bin 4221 -> 4448 bytes SAE_semestre1/img/mur.png | Bin 1289 -> 0 bytes SAE_semestre1/img/oeuf.png | Bin 0 -> 4775 bytes SAE_semestre1/img/pomme.png | Bin 1154 -> 0 bytes SAE_semestre1/img/serpent.png | Bin 493 -> 0 bytes SAE_semestre1/src/Oeuf.c | 27 +++++++++++ SAE_semestre1/src/game.c | 40 ++++++++--------- SAE_semestre1/src/main.c | 49 ++++++++++++-------- SAE_semestre1/src/pastille.c | 30 ------------- SAE_semestre1/src/serpent.c | 69 ++++++++++++++--------------- SAE_semestre1/src/terrain.c | 13 +++--- SAE_semestre1/src/time.c | 38 +++++++--------- 18 files changed, 141 insertions(+), 145 deletions(-) create mode 100755 SAE_semestre1/fichier.h/Oeuf.h delete mode 100755 SAE_semestre1/fichier.h/pastille.h create mode 100644 SAE_semestre1/img/cactus.png delete mode 100755 SAE_semestre1/img/mur.png create mode 100644 SAE_semestre1/img/oeuf.png delete mode 100644 SAE_semestre1/img/pomme.png delete mode 100755 SAE_semestre1/img/serpent.png create mode 100755 SAE_semestre1/src/Oeuf.c mode change 100755 => 100644 SAE_semestre1/src/main.c delete mode 100755 SAE_semestre1/src/pastille.c diff --git a/SAE_semestre1/fichier.h/Oeuf.h b/SAE_semestre1/fichier.h/Oeuf.h new file mode 100755 index 0000000..a998f00 --- /dev/null +++ b/SAE_semestre1/fichier.h/Oeuf.h @@ -0,0 +1,7 @@ +#ifndef OEUF_H +#define OEUF_H + +void InitialiserOeufs(int oeufx[], int oeufy[], int segment); +void Oeuf(int pos_x[], int pos_y[], int oeufx[], int oeufy[], int *segment); + +#endif diff --git a/SAE_semestre1/fichier.h/pastille.h b/SAE_semestre1/fichier.h/pastille.h deleted file mode 100755 index d456071..0000000 --- a/SAE_semestre1/fichier.h/pastille.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef PASTILLE_H -#define PASTILLE_H - -void InitialiserPommes(int pommex[], int pommey[], int segment); -void Pomme(int pos_x[], int pos_y[], int pommex[], int pommey[], int *segment); - -#endif diff --git a/SAE_semestre1/fichier.h/serpent.h b/SAE_semestre1/fichier.h/serpent.h index 738ad6e..42094a5 100755 --- a/SAE_semestre1/fichier.h/serpent.h +++ b/SAE_semestre1/fichier.h/serpent.h @@ -3,6 +3,6 @@ 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[]); +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); #endif diff --git a/SAE_semestre1/fichier.h/terrain.h b/SAE_semestre1/fichier.h/terrain.h index 0ddf113..038c41d 100755 --- a/SAE_semestre1/fichier.h/terrain.h +++ b/SAE_semestre1/fichier.h/terrain.h @@ -1,6 +1,6 @@ #ifndef TERRAIN_H #define TERRAIN_H -void DessinerScene(int murx[30], int mury[30]); +void DessinerScene(int murx[30], int mury[30], int minute, int seconde, char timer []); #endif diff --git a/SAE_semestre1/fichier.h/time.h b/SAE_semestre1/fichier.h/time.h index 8aa397b..038f0bc 100755 --- a/SAE_semestre1/fichier.h/time.h +++ b/SAE_semestre1/fichier.h/time.h @@ -3,5 +3,7 @@ void Score(int segment); +void Update_Timer(int, int, char[]); +void Timer(int*, int*, unsigned long int*, int*, int*, char[]); #endif \ No newline at end of file diff --git a/SAE_semestre1/img/cactus.png b/SAE_semestre1/img/cactus.png new file mode 100644 index 0000000000000000000000000000000000000000..1fdf361d2b5c4293f8bfd654d4fdcff505fc5e54 GIT binary patch literal 5052 zcmeHKX;c$g77hY}EDDH9+o&;)M#M@gl>|sZ1O$W#Q3M(l5Uo^Ipp+~o1q4JJQC!dg zZI>goTk8n8p(3;hBB%(hIHNr?_Owd`anwdyX^#tT$h-=xXZoBuo-_TA)Oo2}_uc!w zd%t(zO=@HKoM3yKu{JCg%U%`|7y<6i%&;B`zW=;&oISYRAQ#A#GTAhiHFyA)W)>_n z#s&!gu@_N1C*?;@Zn;fR zvBT2r=y74Z&a5erEN9cf<{0g7_^Bt&Eys?oIm)(Pm03~gBQ$^=X?<#~(iZTKd*DAPpz;+e8gp>Nq>u0a-cd)#BP&+oRVw z+fujZzIhY8s3wfJBaVc1)A!qq%W1RfTGM2V$!>MyyKQHsFLr&5yZ&;=GRD5)?TnP& zKMixp7+SJ9x8}Bm(pRRT%YJZ#%k1OgQboxlD(;%C+qX35a7DzH!tklA_Jo&m2|L5q z?pRuNdB^g1ETZ`6Kkco8}x6~@QLPGfcFib7-4h&!UN*9MS@R7kpxj7*;s zg{LpWB?QNJhK-K_1pq3N#@Gf`l3I@%q#P423S>sj=devC^fD=D0VtyYjgDlCcp@GQ z1sSLmgfqj2?V}@u@qCg;dj%20{>cpT9O)mt;zZ!1-hnsRE{Y zu&UsbC7A=)=fO~rK&iAQFF^JumNcd8C+m~gm>E+#0|No>eYl@k_vUUg23B%88mPgO zneb$RQVz2|N@#G3Kuw}REQA$a7y==Ln#yiC|CqZFx(3g3K4|_5g;BO9tsl_fuplDIu!=ClTu*`B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png b/SAE_semestre1/img/fond.png index ac9264603dda8850747f2250fc13eb2b6f554987..612857c36206bcb69cb3cbce45bc9633cf2072ea 100755 GIT binary patch delta 690 zcmeyX@IYxoGb8iF7DEqnCI$u(1_lNg?e6ItpkSnDXrO0o!oXl;U}S7%Xk=w%pkQcX zWo%$&WW>P8z_@@JNHTyikYXslFBmiNuVnpFC0)KU0ec1K(oNl67FnWQ0g6|+)>_So z`NirhHAzI={ovLI4~{2YJ$N)SoITu8;15G#X<<;wM4|uFMWT*W6x``A|1MYlo?&5N z;;gHt+!?!amrdq0oE~Bkd{e`dIPl8T_vMC>DT6IBTcijj3A9vS=&X`mGVbUSa1;39L+PO7e(7Uk4 z`rP-8k4^j=9vBxa-TwC~o55$#s=aHE_BHIweeh`4TFvSMPx%Z!q?}mx#>;V*(?W(l z^Dmk|ZTJ_xp#1FXwOjiyvnx2qF3oFbc1~F1ar3p^`*$zjyuEL{_Fo;t^xZ{UfBf&^ zV_@Km&J2ktiSYHYO3vRrnW=$EB`qn*%+M&sNH^8MI9b=k#MDSPDbXTD*F422%_1q; zFxA}HXtFu$DlSU{BNIboBXc9u$*);U*rCxoIgL#n#@;-IO^|W&A+{J5Go#exMAMWc zT}w-|R9zF(G(%lWLsJV~L-RyK6U!tsGb6L4$xiHkP@N{5r?cmAuvk4a+ccR|z}S&j zPD1GQj80%uQSx+g46!(!oReYr@4SQSfg=v723ZeQG%jZAld{Nq5MU_4P#ee;*Y%aB Q8iGND4l$+4ol;{=@~_DUS@IHQy7H)+xb+4%1qAHM3H+WhDIU&~)t<{WKk@Q_Ka zZ_5yRH@^=4e^9!h~-N@v-ovg-vt*NnK zN6BJftSfoCIEGl9PPVDl`(@88$|%e{_27!e#cX|27FiEgG&&!3V9@YnmS#S^!VZ*3 NJYD@<);T3K0RYNC`P~2j diff --git a/SAE_semestre1/img/mur.png b/SAE_semestre1/img/mur.png deleted file mode 100755 index 2c4a479f9d7d143196b7ee9d82a46cb9e7b79e3c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1289 zcmV+k1@`)hP)EX>4Tx04R}tkv&MmKpe$iTcx5c4t9_tlA$`;MMWHI6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfb#YR3krMxx6k5c1aNLh~_a1le0DrT}RI?`msG4PD zQb{3~UloF{2w?zWj3O#AQ=b#XG(5-GJ$!tkM+H?_h|{W(Vj@HPNe_S2@r&e=$yEU( z#{z0lAvu2VKlt6PS)7`5lR`~1&}!KB_pxoaPJqBOaHVzpwI(q8NqVEB z#g2f%ZQ$a%qse=~K2d-P^xs+Wq|ifg*COY|6Hl00006VoOIv0RI600RN!9r;`8x010qNS#tmY z4`BcR4`BhQKc{H`000McNliru=L`!CFb3kj|`0|rS%K~y-)MU=gcBsCO;zjJL@ zRd)|FpcNum5wJPp(RczLfP^Poi42VvqLqMv0Cwr=?y9nV2;5?w*|M+i`Mdh<=ePd- z`4@x$*bN4zv85RVG@u(wK-|x-9V+mcAV=`^x8ITfeD{vGKYou5t(#jDUE&Z1AjkM% ztzvDkBr|6q%&m)$Yw&96l+#ztKm0`Q5*uRgaM@t*A|z@uLQHuStP=aZxG}v3wow+l z#l?kc$iBn8S}+Aq$p{cZ@30DTf(2Lvl4uqF?ZGjd$835ZH2|^zHq&-9FTvFMfN$Xr zr9kc?HPbv^g(2INZqjD3$kX69ccA6b)7C_FuoP%9epQ7PQ4$~s0U^AJO9doKh91xv zXn2_6VKSErwRmi7rSxOtWYn_Mt4$yEtYjo7p8S6V-IXlEEROhrt%q9eD9mGqJi{P^v4s)li@c1yAyEapn;B_`RhCsH-$sD?f zNi5l@4nayb2SIiu+UMVpCX?C-cr}y;w#a$Fz7KT5L!70EE)QCgNT)|40{!~@>_6VW zC+q(=bcTgss2zM-4X7Ue6viGiFciFg^M?NbFjJnA!_&@-00000NkvXXu0mjfxD+;u diff --git a/SAE_semestre1/img/oeuf.png b/SAE_semestre1/img/oeuf.png new file mode 100644 index 0000000000000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Yo7+a3#1=Pe?=_Hom)RZX^Ooqr*N=%Mm80L$a_fDpr zE|7^FCto^wckWo!U^75ig3D7tz>kBysI^X-VC_zm-JYcpa}<2h?U^=!>qHSOp(9ut zkoJ^eQ+FAjipbPRkM3%NonkEB|Apo*4;1Y?@_5Dt*7x#5z8jT9XZxOfk68?Vl^}?} z6l#L>ZNWw4(i9&j;POq88H6pJ2Gzr#uHECzucQJIMO$PFl!R$a0kVmn5CZOghjJXa&-f*9wZ{4{CB>v^#_5P5}r8gDgXlZox3WU{e2v zrCiPE-f^__7n(%#fL=ug`1!^_@dC9_+EWbunsH_4H~jd|;x}9YQ1>tLQu_AG)i2je zDezL@{_N_P>!lQUDR6&w{omvYe(^d*+rVEzZt$|Sr=x8Gc+m;Luv z7#Zw{pYIX~LPl^+DEMgeC@?sP)f-|5wG9ayfy*Urg_YnR0I_;qj4A5WrP8`gQ%qR% zo376Lwce7Q=QD<1h>Ra73Kkzc zHRAuzl|oaq33+>+^X;hdpM?53cZ- zupihzsoJVcQ`(zOpKe;hG|<&&7r?AYyCLa)wkY^Vm&hb4C{H<3IPxFj*0Fn!9xp6! zyZP+QKhJlSMRtDp=pO$0ogKBtrsm=IpIIZ<-y}{n)VQ`ysJK!(v`dkZeowOQTXA?E zG-fQcaomJO#1uyPL3K9_+X05bLYFvufL4U5)C~xQ_&2~ zd4NDgalbPTNu0jp?bGuDDnc7GSKQdO^sAk(zLhj%aQ*Ib$%!?uL_E=7jFayOT0CXd z2w_Bxd9<-eACt*o%emyC93)?o_gI~-*ULR s<>4zw4{h7({p88hGsVxJj(8gQSK9(||NE(OkYfUU>>OR?%q1)S3vOtt&;S4c literal 0 HcmV?d00001 diff --git a/SAE_semestre1/img/pomme.png b/SAE_semestre1/img/pomme.png deleted file mode 100644 index 0514da1040212a9e6f4c76f44dcd24ec02bbfef6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1154 zcmV-|1bzF7P)3_D^Se9SZ3``>&~4d*l#~V#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zyLOFxH_5)ub$vBl-y4-`A}G0)>;+5~#{*|XYi}Ot|77IDd;fXhPWzyp_}}Ay0i_Yq U;cLpiivR!s07*qoM6N<$f|TVR+yDRo diff --git a/SAE_semestre1/img/serpent.png b/SAE_semestre1/img/serpent.png deleted file mode 100755 index cdeccde6ed138d6ea09ffd7cc6cadefee82d41b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 493 zcmVrd-(Wz7v)*r=l&c6O2K4+Pb7{r-LQx^h+~_U&Uv3W%*v8N zd`>)R&;^Mfxh}i>#<}FMz%#=}HZxBgCKgLwEO#+08!GV(aYRuy$`^7jE1b7DtJOMd z-;=*ERM1wIxlVHwNi1RsX^4<4==ICRYWF91EyHh2;3b z|KNAGW^sDTO$sG|z>95vj03@4pw+PL?_=9;odEu4;7aTGYfWJGlk`SMiyQ%i+rY(j zN0aw}%N=0&NtX=Ck^D4;Vi9;hqi@OsL$^Txn%i4@AEysMmbyya00)P_M2WK3J>K2h z-P^xs+Wq|it>|*TJS!=E00003b3#c}2nYz<;ZNWI0013HL_t(Ijbl`_zs5i=U?N-R jsOC}4qnbxGQ$;fXCZz#h@lj{Z00000NkvXXu0mjfa(L9m diff --git a/SAE_semestre1/src/Oeuf.c b/SAE_semestre1/src/Oeuf.c new file mode 100755 index 0000000..00953a7 --- /dev/null +++ b/SAE_semestre1/src/Oeuf.c @@ -0,0 +1,27 @@ +#include +#include +#include "../fichier.h/Oeuf.h" + +void InitialiserOeufs(int oeufx[], int oeufy[], int segment) { + int p; + int oeuf; + for (p = 0; p < 5; p++) { + oeufx[p] = ((rand() % (55) + 1) * 20); + oeufy[p] = ((rand() % (35) + 1) * 20); + ChargerImage("../img/oeuf.png", oeufx[p], oeufy[p],0,0, 20,20); + } +} +void Oeuf(int pos_x[], int pos_y[], int oeufx[], int oeufy[], int *segment){ + int p; + int oeuf; + for (p = 0; p < 5; p++) { + ChargerImage("../img/oeuf.png", oeufx[p], oeufy[p],0,0, 20,20); + } + for(p=0; p<5; p++){ + if(oeufx[p]==pos_x[0] && oeufy[p]==pos_y[0]){ + (*segment) +=2; + oeufx[p] = ((rand() % (55)+1)*20); + oeufy[p] = ((rand() % (35)+1)*20); + } + } +} \ No newline at end of file diff --git a/SAE_semestre1/src/game.c b/SAE_semestre1/src/game.c index b4a4827..b5d4e56 100755 --- a/SAE_semestre1/src/game.c +++ b/SAE_semestre1/src/game.c @@ -8,16 +8,15 @@ void DessinerScene(int murx[], int mury[], int minute, int seconde, char timer []){ int mur; int i; - int fond; snprintf(timer,6,"%02d:%02d", minute ,seconde); - ChoisirCouleurDessin(CouleurParComposante(79,80,35)); + ChoisirCouleurDessin(CouleurParComposante(218,209,77)); RemplirRectangle(20,20,1160,700); ChoisirCouleurDessin(CouleurParComposante(255,255,255)); srand(time(NULL)); for(i=0; i<30; i++){ murx[i] = ((rand() % (55)+1)*20); mury[i] = ((rand() % (35)+1)*20); - ChargerImage("../img/mur.png", murx[i], mury[i],0,0, 20,20); + ChargerImage("../img/cactus.png", murx[i], mury[i],0,0, 20,20); } } void Score(int segment){ @@ -59,12 +58,10 @@ void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_ pos_x[0]=old_x[0]+20; } for (i=0 ; i #include #include "../fichier.h/serpent.h" -#include "../fichier.h/pastille.h" +#include "../fichier.h/Oeuf.h" #include "../fichier.h/time.h" #include "../fichier.h/main.h" #define CYCLE 10000L -int main(void) { +int main(void){ int segment = 10; int go_on = 1; int direction = 4; - int pos_x[60]; - int pos_y[60]; - int old_x[60]; - int old_y[60]; - int pommex[5]; - int pommey[5]; + int minute = 0; + int seconde = 0; + int seconde_actuel = 0; + int old_seconde = 0; + unsigned long int suivant; + int pos_x[2400]; + int pos_y[2400]; + int old_x[2400]; + int old_y[2400]; + int oeufx[5]; + int oeufy[5]; int murx[30]; int mury[30]; + char timer[6]; int *pointeur_segment = &segment; int *pointeur_go_on = &go_on; int *pointeur_direction = &direction; + int *pointeur_minute = &minute; + int *pointeur_seconde = &seconde; + 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)); - /* suivant = Microsecondes()+CYCLE; - old_seconde=(suivant/1000000)%10;*/ - DessinerScene(murx, mury); - InitialiserPommes(pommex, pommey, segment); + 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){ - /*Timer();*/ - Score(*pointeur_segment); + Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer); + Score(segment); Controle(pointeur_direction, 0, pointeur_go_on); - Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, pointeur_go_on, pointeur_direction); - Pomme(pos_x, pos_y, pommex, pommey, pointeur_segment); + 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); + usleep(100000); + Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment); } - usleep(100000); FermerGraphique(); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/SAE_semestre1/src/pastille.c b/SAE_semestre1/src/pastille.c deleted file mode 100755 index a5499af..0000000 --- a/SAE_semestre1/src/pastille.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include "../fichier.h/pastille.h" - -void InitialiserPommes(int pommex[], int pommey[], int segment) { - int p; - int pomme; - pomme = ChargerSprite("../img/pomme.png"); - for (p = 0; p < 5; p++) { - pommex[p] = ((rand() % (55) + 1) * 20); - pommey[p] = ((rand() % (35) + 1) * 20); - AfficherSprite(pomme, pommex[p], pommey[p]); - } -} - -void Pomme(int pos_x[], int pos_y[], int pommex[], int pommey[], int *segment) { - int p; - int pomme; - pomme=ChargerSprite("../img/pomme.png"); - for (p = 0; p < 5; p++) { - AfficherSprite(pomme, pommex[p],pommey[p]); - } - for(p=0; p<5; p++){ - if(pommex[p]==pos_x[0] && pommey[p]==pos_y[0]){ - (*segment) +=2; - pommex[p] = ((rand() % (60)+1)*20); - pommey[p] = ((rand() % (27)+1)*20); - } - } -} \ No newline at end of file diff --git a/SAE_semestre1/src/serpent.c b/SAE_semestre1/src/serpent.c index 190aa38..117bf06 100755 --- a/SAE_semestre1/src/serpent.c +++ b/SAE_semestre1/src/serpent.c @@ -1,38 +1,53 @@ #include #include "../fichier.h/serpent.h" -void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[]){ +void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int* direction){ int i = 0; - int serpent; - AfficherSprite(serpent, pos_x[0], pos_y[0]); for (i=1 ; i1160 || pos_x[0]<=20){ + if (pos_x[0] >1160 || pos_x[0]<=0){ *go_on=0; } /*Serpent contre coté*/ - if (pos_y[0]<40 || pos_y[0] >=700){ + if (pos_y[0]<20 || pos_y[0] >=700){ *go_on=0; } /*Serpent contre Serpent*/ for (i = 1; i < segment; i++) { - if (pos_x[0] == pos_x[i] && pos_y[0] == pos_y[i]) + if (pos_x[0] == pos_x[i] && pos_y[0] == pos_y[i]){ *go_on = 0; + } } /*Serpent contre mur*/ for(i=0; i<30;i++){ @@ -41,6 +56,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) { int t; while(ToucheEnAttente()) { @@ -77,30 +93,13 @@ void Controle(int *direction, int last_direction, int *go_on) { } 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) { int serpent; - int x = 600; - int y = 400; - int i = 0; - serpent=ChargerSprite("../img/serpent.png"); + int i = 0; + pos_x[0] = 600; + pos_y[0] = 400; for (i = 0; i < *segment; i++){ - AfficherSprite(serpent, x-(i*20), y); - pos_x[i]=x-(i*20); - pos_y[i]=y; + pos_x[i]= pos_x[0]; + pos_y[i]= pos_y[0]; old_x[i]=pos_x[i]; old_y[i]=pos_y[i]; } - if (*direction == 1 && *direction != 2 ){ - pos_y[0]=old_y[0]-20; - } - if (*direction == 2 && *direction != 1) { - pos_y[0]=old_y[0]+20; - } - if (*direction == 3 & *direction != 4) { - pos_x[0]=old_x[0]-20; - } - if (*direction == 4 && *direction != 3) { - pos_x[0]=old_x[0]+20; - } - Update_Serpent(pos_x, pos_y, *segment, old_x, old_y); - Collision_Serpent(pos_x, pos_y, *segment, murx, mury, go_on); - usleep(100000); } \ No newline at end of file diff --git a/SAE_semestre1/src/terrain.c b/SAE_semestre1/src/terrain.c index 74b66d7..19d84a4 100755 --- a/SAE_semestre1/src/terrain.c +++ b/SAE_semestre1/src/terrain.c @@ -4,22 +4,19 @@ #include "../fichier.h/terrain.h" #include "../fichier.h/serpent.h" #include "../fichier.h/main.h" -#include "../fichier.h/pastille.h" +#include "../fichier.h/Oeuf.h" -void DessinerScene(int murx[30], int mury[30]){ +void DessinerScene(int murx[], int mury[], int minute, int seconde, char timer []){ int mur; int i; - int fond; - /* snprintf(timer,6,"%02d:%02d", minute ,seconde);*/ - ChoisirCouleurDessin(CouleurParComposante(91,222,122)); + snprintf(timer,6,"%02d:%02d", minute ,seconde); + ChoisirCouleurDessin(CouleurParComposante(218,209,77)); RemplirRectangle(20,20,1160,700); ChoisirCouleurDessin(CouleurParComposante(255,255,255)); - fond = ChargerSprite("../img/fond.png"); - mur = ChargerSprite("../img/mur.png"); srand(time(NULL)); for(i=0; i<30; i++){ murx[i] = ((rand() % (55)+1)*20); mury[i] = ((rand() % (35)+1)*20); - AfficherSprite(mur, murx[i], mury[i]); + ChargerImage("../img/cactus.png", murx[i], mury[i],0,0, 20,20); } } diff --git a/SAE_semestre1/src/time.c b/SAE_semestre1/src/time.c index b4408d0..1a6b578 100755 --- a/SAE_semestre1/src/time.c +++ b/SAE_semestre1/src/time.c @@ -6,17 +6,10 @@ #include "../fichier.h/serpent.h" #define CYCLE 10000L -int seconde=0; -int minute=0; -int seconde_actuel=0; -int old_seconde=0; -unsigned long int suivant; -char timer[6]; - void Score(int segment){ int nombre; char score[4]; - nombre= (segment-10)*10; + nombre= (segment-10)*25; snprintf(score,4,"%04d0", nombre); ChoisirCouleurDessin(CouleurParNom("black")); RemplirRectangle(1100,700,1200,800); @@ -24,7 +17,7 @@ void Score(int segment){ EcrireTexte(1000,760,"Score: ",2); EcrireTexte(1100,760,score,2); } -void Update_Timer(){ +void Update_Timer(int minute, int seconde, char timer[]){ snprintf(timer,6,"%02d:%02d", minute, seconde); ChoisirCouleurDessin(CouleurParComposante(0,0,0)); RemplirRectangle(10,700,12000,800); @@ -32,21 +25,20 @@ void Update_Timer(){ EcrireTexte(50,760,"time: ",2); EcrireTexte(120,760,timer,2); } -void Timer(){ - if(Microsecondes()> suivant){ - suivant = Microsecondes()+CYCLE; - seconde_actuel = (suivant/1000000)%10; +void Timer(int *minute, int *seconde, unsigned long int *suivant, int *seconde_actuel, int *old_seconde, char timer[]){ + if(Microsecondes()> *suivant){ + *suivant = Microsecondes()+CYCLE; + *seconde_actuel = (*suivant/1000000)%10; if(seconde_actuel !=old_seconde){ - old_seconde = seconde_actuel; - if(seconde == 59){ - minute=minute+1; - seconde=0; - Update_Timer(); - }else;{ - seconde = seconde+1; - Update_Timer(); + *old_seconde = *seconde_actuel; + if(*seconde == 59){ + *minute=*minute+1; + *seconde=0; + Update_Timer(*minute, *seconde, timer); + }else{ + *seconde = *seconde+1; + Update_Timer(*minute, *seconde, timer); } } } -} - +} \ No newline at end of file