#include #include "../fichier.h/serpent.h" void Update_Serpent(int pos_x[], int pos_y[], int segment, int old_x[], int old_y[], int* direction){ int i = 0; for (i=1 ; i1160 || pos_x[0]<=0){ *go_on=0; } /*Serpent contre coté*/ 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]){ *go_on = 0; } } /*Serpent contre mur*/ for(i=0; i<30;i++){ if(pos_x[0] == murx[i] && pos_y[0] == mury[i]){ *go_on=0; } } } void Controle(int *direction, int last_direction, int *go_on, int *pause) { int t; while(ToucheEnAttente()) { t = Touche(); switch(t) { case XK_Left: if (last_direction != 4) { *direction = 3; } return; case XK_Right: if (last_direction != 3) { *direction = 4; } return; case XK_Up: if (last_direction != 2) { *direction = 1; } return; case XK_Down: if (last_direction != 1) { *direction = 2; } return; case XK_Escape: *direction = 0; *go_on = 0; return; case XK_space: if (*pause == 0 ){ *pause == 1; }else{ *pause = 0; ChargerImage("../img/PAUSE.png", 400,200,0,0,350,300); } } } } 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 i = 0; pos_x[0] = 600; pos_y[0] = 400; for (i = 0; i < *segment; i++){ pos_x[i]= pos_x[0]; pos_y[i]= pos_y[0]; old_x[i]=pos_x[i]; old_y[i]=pos_y[i]; } }