2023-11-30 09:54:00 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <graph.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2023-12-07 14:02:18 +01:00
|
|
|
#include "fonction.h"
|
2023-11-30 09:54:00 +01:00
|
|
|
#define CYCLE 10000L
|
|
|
|
|
2023-12-07 14:02:18 +01:00
|
|
|
|
2023-12-10 17:09:46 +01:00
|
|
|
int seconde=0, minute=0, seconde_actuel, old_seconde;
|
2023-11-30 09:54:00 +01:00
|
|
|
char timer[6];
|
|
|
|
unsigned long int suivant;
|
2023-12-11 14:42:47 +01:00
|
|
|
long int vitesse=100000;
|
2023-12-07 14:02:18 +01:00
|
|
|
|
2023-11-30 09:54:00 +01:00
|
|
|
int serpent;
|
2023-12-10 17:09:46 +01:00
|
|
|
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;
|
2023-12-10 12:27:36 +01:00
|
|
|
int pos_x[2400], pos_y[2400], old_x[2400], old_y[2400];
|
2023-12-10 17:55:25 +01:00
|
|
|
int tete_up, tete_down, tete_right, tete_left, queue_up, queue_down, queue_left, queue_right;
|
2023-12-07 14:02:18 +01:00
|
|
|
|
2023-12-10 17:09:46 +01:00
|
|
|
int p=0, pp=0, pomme, pommex[5], pommey[5];
|
2023-12-04 17:01:52 +01:00
|
|
|
int fond, Nbr;
|
|
|
|
char score[4];
|
|
|
|
|
|
|
|
int go_on=1;
|
2023-12-10 13:11:43 +01:00
|
|
|
int go_menu=1;
|
2023-12-10 14:52:16 +01:00
|
|
|
int imageMenu;
|
|
|
|
int go_menu2=1;
|
2023-12-10 13:11:43 +01:00
|
|
|
int t2;
|
2023-12-10 14:52:16 +01:00
|
|
|
int t3;
|
2023-11-30 09:59:11 +01:00
|
|
|
|
|
|
|
/*Fonction Principale*/
|
|
|
|
int main(){
|
2023-12-10 13:11:43 +01:00
|
|
|
/* paramétrage de la fenêtre + chargement première scène */
|
2023-11-30 09:54:00 +01:00
|
|
|
InitialiserGraphique();
|
2023-11-30 09:59:11 +01:00
|
|
|
CreerFenetre(350,100,1200,800);
|
2023-12-10 14:52:16 +01:00
|
|
|
|
|
|
|
MenuDebut();
|
|
|
|
|
|
|
|
while(go_menu2){
|
|
|
|
while(ToucheEnAttente()){
|
|
|
|
t3 = Touche();
|
|
|
|
switch(t3){
|
|
|
|
case XK_q :
|
|
|
|
FermerGraphique();
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
break;
|
|
|
|
case XK_Right:
|
|
|
|
go_menu2=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-30 09:59:11 +01:00
|
|
|
EffacerEcran(CouleurParComposante(0,0,0));
|
2023-12-04 17:01:52 +01:00
|
|
|
suivant=Microsecondes()+CYCLE;
|
2023-11-30 09:59:11 +01:00
|
|
|
old_seconde=(suivant/1000000)%10;
|
2023-11-30 09:54:00 +01:00
|
|
|
DessinerScene();
|
2023-11-30 09:59:11 +01:00
|
|
|
|
2023-12-04 17:01:52 +01:00
|
|
|
/*Boucle Principale du Programme*/
|
2023-11-30 09:59:11 +01:00
|
|
|
while(go_on){
|
|
|
|
Timer();
|
2023-12-04 17:01:52 +01:00
|
|
|
Score();
|
|
|
|
Collision();
|
2023-11-30 09:59:11 +01:00
|
|
|
Controle();
|
2023-12-10 14:52:16 +01:00
|
|
|
Serpent();
|
2023-11-30 09:59:11 +01:00
|
|
|
Pomme();
|
|
|
|
}
|
|
|
|
|
2023-12-10 13:11:43 +01:00
|
|
|
/* fermeture de la fenêtre si ECHAP pressé + Menu de Fin*/
|
|
|
|
MenuDeFin();
|
|
|
|
|
|
|
|
while(go_menu){
|
|
|
|
while(ToucheEnAttente()){
|
|
|
|
t2 = Touche();
|
|
|
|
switch(t2){
|
|
|
|
case XK_q :
|
|
|
|
go_menu=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-30 09:54:00 +01:00
|
|
|
FermerGraphique();
|
2023-11-30 09:59:11 +01:00
|
|
|
return EXIT_SUCCESS;
|
2023-12-04 17:01:52 +01:00
|
|
|
}
|