SAE11_2023/SAE_semestre1/src/main.c

71 lines
2.1 KiB
C
Raw Normal View History

#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"
#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-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 go_on=1;
2023-12-21 12:29:12 +01:00
int pause = 1;
2023-12-19 14:52:23 +01:00
int segment = 10;
int direction = 4;
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];
char timer[6];
2023-12-19 14:52:23 +01:00
int *pointeur_segment = &segment;
int *pointeur_direction = &direction;
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;
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, &go_on, pointeur_direction);
bordure(segment);
Update_Serpent(pos_x, pos_y, segment, old_x, old_y, pointeur_direction);
while(go_on==1){
Controle(pointeur_direction, 0, &go_on, pointeur_pause);
2023-12-21 12:29:12 +01:00
if(pause == 1){
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);
dessinerSerpent(pos_x, pos_y, segment, old_x, old_y);
Collision_Serpent(pos_x, pos_y, segment, murx, mury, &go_on);
usleep(90000);
Oeuf(pos_x, pos_y, oeufx, oeufy, pointeur_segment);
}
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));
Menu();
if(Menu() == 1){
2023-12-21 12:29:12 +01:00
lancer_jeu();
}
FermerGraphique();
2023-12-19 14:52:23 +01:00
return EXIT_SUCCESS;
}
2023-12-21 12:29:12 +01:00