Amelioration code + commentaires. Rectifications erreurs etc.

This commit is contained in:
Vincent
2023-12-24 01:48:21 +01:00
parent 494177f3c1
commit d34541178a
9 changed files with 232 additions and 46 deletions

58
main.c
View File

@@ -2,7 +2,7 @@
#include <stdio.h>
#include <graph.h>
#include <time.h>
#include "evenement.h"
#include "evenements.h"
#include "main.h"
#include "gui.h"
#include "scene.h"
@@ -114,12 +114,57 @@ int main()
while(game_on) /* Lancement du cycle pour les Inputs et le Jeu*/
{
if(Touches(&direction,&direction_davant,&pause))
if (ToucheEnAttente() == 1)
{
FinJeu(serpent,pastilles,obstacle);
return EXIT_SUCCESS;
}
switch (Touche())
{
case XK_Up:
direction = 1;
if(direction_davant == 3 && direction == 1)
{
direction = direction_davant;
}
break;
case XK_Down:
direction = 3;
if(direction_davant == 1 && direction == 3)
{
direction = direction_davant; /* Changements de direction du serpent */
}
break;
case XK_Left:
direction = 0;
if(direction_davant == 2 && direction == 0)
{
direction = direction_davant;
}
break;
case XK_Right:
direction = 2;
if(direction_davant == 0 && direction == 2)
{
direction = direction_davant;
}
break;
case XK_space:
if(pause ==0)
{
pause=1;
break;
}
pause=0;
break;
case XK_Escape:
if(pause == 1)
{
FinJeu(serpent,pastilles,obstacle);
return EXIT_SUCCESS;
}
break;
}
}
if(pause==1)
{
Pause();
@@ -161,5 +206,4 @@ int main()
}
FinJeu(serpent,pastilles,obstacle);
return EXIT_SUCCESS;
}
}