#include #include #include #include "../fichier.h/serpent.h" #include "../fichier.h/terrain.h" #include "../fichier.h/pastille.h" void Update_Serpent(int segment, int direction, int pos_x[60], int pos_y[60]){ int old_x[60]; int old_y[60]; int x = 600; int y = 400; int t, fond, i = 0, serpent; fond = ChargerSprite("../img/fond.png"); AfficherSprite(fond, pos_x[segment-1], pos_y[segment-1]); AfficherSprite(serpent, pos_x[0], pos_y[0]); 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; } for (i=1 ; i1160 || pos_x[0]<=20){ return *go_on= 0; } else{ return 1; } /*Serpent contre coté*/ if (pos_y[0]<40 || pos_y[0] >=700){ return *go_on= 0; } else{ return 1; } /*Serpent contre Serpent*/ for (i = 1; i < segment; i++) { if (pos_x[0] == pos_x[i] && pos_y[0] == pos_y[i]){ return *go_on = 0; } else { return 1; } } /*Serpent contre mur*/ for(i=0; i<30;i++){ if(pos_x[0] == murx[i] && pos_y[0] == mury[i]){ return *go_on= 0; }else{ return 1; } } } void Score(int segment){ int nombre; char score[4]; nombre = (segment-10)*10; snprintf(score,4,"%04d0", nombre); ChoisirCouleurDessin(CouleurParNom("black")); RemplirRectangle(1100,700,1200,800); ChoisirCouleurDessin(CouleurParNom("white")); EcrireTexte(1000,760,"Score: ",2); EcrireTexte(1100,760,score,2); } void Serpent(int* go_on) { int direction=0; int pos_x[60]; int pos_y[60]; int* pointeur_pos_x= pos_x; int* pointeur_pos_y= pos_y; int* pointeur_direction=&direction; Controle(pointeur_direction, go_on); Update_Serpent(segment, direction, pointeur_pos_x, pointeur_pos_y ); Collision_Serpent(go_on); }