diff --git a/JEUX_SERPENT/Jeux b/JEUX_SERPENT/Jeux index a998108..76d5d9a 100755 Binary files a/JEUX_SERPENT/Jeux and b/JEUX_SERPENT/Jeux differ diff --git a/JEUX_SERPENT/main.c b/JEUX_SERPENT/main.c index 4cdfec5..6e9649d 100644 --- a/JEUX_SERPENT/main.c +++ b/JEUX_SERPENT/main.c @@ -7,15 +7,15 @@ #define CYCLE 10000L -int seconde, minute, seconde_actuel, old_seconde; +int seconde=0, minute=0, seconde_actuel, old_seconde; char timer[6]; unsigned long int suivant; int serpent; -int x=500, y=360, direction=4, t, segment=10, i=0; +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 p, pp, pomme, pommex[5], pommey[5]; +int p=0, pp=0, pomme, pommex[5], pommey[5]; int fond, Nbr; char score[4]; diff --git a/JEUX_SERPENT/serpent.c b/JEUX_SERPENT/serpent.c index 846aa94..26b9fec 100644 --- a/JEUX_SERPENT/serpent.c +++ b/JEUX_SERPENT/serpent.c @@ -9,22 +9,27 @@ void Controle(){ while(ToucheEnAttente()){ t = Touche(); - switch(t){ + switch(t){ case XK_Left : - direction=3; - break; + if (direction != 4){ + direction=3; + break; + } case XK_Right: - direction=4; - break; + if (direction != 3){ + direction=4; + break; + } case XK_Up: - direction=1; - break; + if(direction !=2){ + direction=1; + break; + } case XK_Down: - direction=2; - break; - case XK_Escape: - go_on=0; - break; + if (direction !=1){ + direction=2; + break; + } } } }