diff --git a/JEUX_SERPENT/IMG/queue_down.png b/JEUX_SERPENT/IMG/queue_down.png new file mode 100644 index 0000000..e4bbda1 Binary files /dev/null and b/JEUX_SERPENT/IMG/queue_down.png differ diff --git a/JEUX_SERPENT/IMG/queue_left.png b/JEUX_SERPENT/IMG/queue_left.png new file mode 100644 index 0000000..f70d25f Binary files /dev/null and b/JEUX_SERPENT/IMG/queue_left.png differ diff --git a/JEUX_SERPENT/IMG/queue_right.png b/JEUX_SERPENT/IMG/queue_right.png new file mode 100644 index 0000000..f152198 Binary files /dev/null and b/JEUX_SERPENT/IMG/queue_right.png differ diff --git a/JEUX_SERPENT/IMG/queue_up.png b/JEUX_SERPENT/IMG/queue_up.png new file mode 100644 index 0000000..a198f65 Binary files /dev/null and b/JEUX_SERPENT/IMG/queue_up.png differ diff --git a/JEUX_SERPENT/IMG/tete_down.png b/JEUX_SERPENT/IMG/tete_down.png new file mode 100644 index 0000000..59bcd6a Binary files /dev/null and b/JEUX_SERPENT/IMG/tete_down.png differ diff --git a/JEUX_SERPENT/IMG/tete_left.png b/JEUX_SERPENT/IMG/tete_left.png new file mode 100644 index 0000000..df5e48c Binary files /dev/null and b/JEUX_SERPENT/IMG/tete_left.png differ diff --git a/JEUX_SERPENT/IMG/tete_right.png b/JEUX_SERPENT/IMG/tete_right.png new file mode 100644 index 0000000..03ef4bf Binary files /dev/null and b/JEUX_SERPENT/IMG/tete_right.png differ diff --git a/JEUX_SERPENT/IMG/tete_up.png b/JEUX_SERPENT/IMG/tete_up.png new file mode 100644 index 0000000..83ccbb0 Binary files /dev/null and b/JEUX_SERPENT/IMG/tete_up.png differ diff --git a/JEUX_SERPENT/Jeux b/JEUX_SERPENT/Jeux index 76d5d9a..b60735f 100755 Binary files a/JEUX_SERPENT/Jeux and b/JEUX_SERPENT/Jeux differ diff --git a/JEUX_SERPENT/fonction.h b/JEUX_SERPENT/fonction.h index 1bea102..6ec55fb 100644 --- a/JEUX_SERPENT/fonction.h +++ b/JEUX_SERPENT/fonction.h @@ -11,7 +11,7 @@ extern int seconde, minute, seconde_actuel, old_seconde; extern char timer[6]; extern unsigned long int suivant; -extern int serpent; +extern int serpent, tete_up, tete_down, tete_right, tete_left, queue_up, queue_down, queue_left, queue_right; extern int x, y, direction, t, segment, i; extern int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400]; diff --git a/JEUX_SERPENT/main.c b/JEUX_SERPENT/main.c index 6e9649d..f877b2e 100644 --- a/JEUX_SERPENT/main.c +++ b/JEUX_SERPENT/main.c @@ -14,6 +14,7 @@ unsigned long int suivant; int serpent; int x=500, y=360, direction=4 /*1 : vers le haut, 2 : vers le bas, 3 vers la gauche, 4 vers la droite*/, t, segment=10, i=0; int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400]; +int tete_up, tete_down, tete_right, tete_left, queue_up, queue_down, queue_left, queue_right; int p=0, pp=0, pomme, pommex[5], pommey[5]; int fond, Nbr; @@ -74,11 +75,6 @@ int main(){ case XK_q : go_menu=0; break; - /*case XK_r : - system("make run"); - sleep(1); - FermerGraphique(); - return EXIT_SUCCESS; */ } } } diff --git a/JEUX_SERPENT/scene.c b/JEUX_SERPENT/scene.c index 0afaabb..77d0780 100644 --- a/JEUX_SERPENT/scene.c +++ b/JEUX_SERPENT/scene.c @@ -21,6 +21,15 @@ void DessinerScene(){ EcrireTexte(10,760,timer,2); serpent=ChargerSprite("IMG/serpent.png"); fond=ChargerSprite("IMG/fond.png"); + tete_up = ChargerSprite("IMG/tete_up.png"); + tete_down =ChargerSprite("IMG/tete_down.png"); + tete_left = ChargerSprite("IMG/tete_left.png"); + tete_right = ChargerSprite("IMG/tete_right.png"); + queue_up = ChargerSprite("IMG/queue_up.png"); + queue_down = ChargerSprite("IMG/queue_down.png"); + queue_left = ChargerSprite("IMG/queue_left.png"); + queue_right = ChargerSprite("IMG/queue_right.png"); + for (i = 0; i < segment; i++){ AfficherSprite(serpent, x-(i*20), y); diff --git a/JEUX_SERPENT/serpent.c b/JEUX_SERPENT/serpent.c index 26b9fec..f6b7228 100644 --- a/JEUX_SERPENT/serpent.c +++ b/JEUX_SERPENT/serpent.c @@ -64,15 +64,46 @@ void Serpent(){ /*fonction pour mettre à jour la position du serpent*/ void Update_Serpent(){ + AfficherSprite(fond, pos_x[segment-1], pos_y[segment-1]); - AfficherSprite(serpent, pos_x[0], pos_y[0]); + /*affichage de la tete en fonction de la direction du serpent*/ + if (direction==1){ + AfficherSprite(tete_up, pos_x[0], pos_y[0]); + } + if (direction==2){ + AfficherSprite(tete_down, pos_x[0], pos_y[0]); + } + if (direction==3){ + AfficherSprite(tete_left, pos_x[0], pos_y[0]); + } + if (direction==4){ + AfficherSprite(tete_right, pos_x[0], pos_y[0]); + } + + /*affichage du reste du corps*/ for (i=1 ; i