2023-12-14 15:00:02 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2023-12-19 14:52:23 +01:00
|
|
|
#include <graph.h>
|
2023-12-19 17:27:47 +01:00
|
|
|
#include "../fichier.h/serpent.h"
|
2023-12-20 21:26:34 +01:00
|
|
|
#include "../fichier.h/Oeuf.h"
|
2023-12-19 17:27:47 +01:00
|
|
|
#include "../fichier.h/time.h"
|
|
|
|
#include "../fichier.h/main.h"
|
2023-12-21 12:29:12 +01:00
|
|
|
#include "../fichier.h/menu.h"
|
2023-12-01 13:32:18 +01:00
|
|
|
|
2023-12-21 12:29:12 +01:00
|
|
|
#define CYCLE 100000L
|
2023-12-19 14:52:23 +01:00
|
|
|
|
2023-12-21 12:29:12 +01:00
|
|
|
int lancer_jeu(){
|
|
|
|
int pause = 1;
|
2023-12-19 14:52:23 +01:00
|
|
|
int segment = 10;
|
|
|
|
int go_on = 1;
|
|
|
|
int direction = 4;
|
2023-12-20 21:26:34 +01:00
|
|
|
int minute = 0;
|
|
|
|
int seconde = 0;
|
|
|
|
int seconde_actuel = 0;
|
|
|
|
int old_seconde = 0;
|
|
|
|
unsigned long int suivant;
|
|
|
|
int pos_x[2400];
|
|
|
|
int pos_y[2400];
|
|
|
|
int old_x[2400];
|
|
|
|
int old_y[2400];
|
|
|
|
int oeufx[5];
|
|
|
|
int oeufy[5];
|
2023-12-19 14:52:23 +01:00
|
|
|
int murx[30];
|
|
|
|
int mury[30];
|
2023-12-20 21:26:34 +01:00
|
|
|
char timer[6];
|
2023-12-19 14:52:23 +01:00
|
|
|
int *pointeur_segment = &segment;
|
|
|
|
int *pointeur_go_on = &go_on;
|
|
|
|
int *pointeur_direction = &direction;
|
2023-12-20 21:26:34 +01:00
|
|
|
int *pointeur_minute = &minute;
|
|
|
|
int *pointeur_seconde = &seconde;
|
|
|
|
unsigned long int *pointeur_suivant = &suivant;
|
|
|
|
int *pointeur_seconde_actuel = &seconde_actuel;
|
|
|
|
int *pointeur_old_seconde = &old_seconde;
|
2023-12-21 12:29:12 +01:00
|
|
|
int *pointeur_pause = &pause;
|
2023-12-20 21:26:34 +01:00
|
|
|
suivant = Microsecondes()+CYCLE;
|
|
|
|
old_seconde=(suivant/1000000)%10;
|
|
|
|
DessinerScene(murx, mury, minute, seconde ,timer);
|
|
|
|
InitialiserOeufs(oeufx, oeufy, segment);
|
|
|
|
Serpent(pos_x, pos_y, old_x, old_y, pointeur_segment, murx, mury, pointeur_go_on, pointeur_direction);
|
2023-12-19 14:52:23 +01:00
|
|
|
while(go_on){
|
2023-12-21 12:29:12 +01:00
|
|
|
Controle(pointeur_direction, 0, pointeur_go_on, pointeur_pause);
|
|
|
|
if(pause == 1){
|
2023-12-20 21:26:34 +01:00
|
|
|
Timer( pointeur_minute, pointeur_seconde, pointeur_suivant, pointeur_seconde_actuel, pointeur_old_seconde, timer);
|
|
|
|
Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction);
|
|
|
|
Collision_Serpent(pos_x, pos_y, segment, murx, mury, pointeur_go_on);
|
2023-12-21 12:29:12 +01:00
|
|
|
Score(segment);
|
2023-12-20 21:26:34 +01:00
|
|
|
usleep(100000);
|
|
|
|
Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment);
|
2023-12-14 15:00:02 +01:00
|
|
|
}
|
2023-12-21 12:29:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
int main(void){
|
|
|
|
int choix = 0;
|
|
|
|
InitialiserGraphique();
|
|
|
|
CreerFenetre(350,100,1200,900);
|
|
|
|
EffacerEcran(CouleurParComposante(0,0,0));
|
|
|
|
afficher_menu(&choix);
|
|
|
|
|
|
|
|
while( choix == 1){
|
|
|
|
lancer_jeu();
|
|
|
|
}
|
2023-12-14 15:00:02 +01:00
|
|
|
FermerGraphique();
|
2023-12-19 14:52:23 +01:00
|
|
|
return EXIT_SUCCESS;
|
2023-12-20 21:26:34 +01:00
|
|
|
}
|
2023-12-21 12:29:12 +01:00
|
|
|
|