SAE11_2023/JEUX_SERPENT/main.c

50 lines
1.0 KiB
C
Raw Normal View History

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
int seconde, minute, seconde_actuel, old_seconde;
2023-11-30 09:54:00 +01:00
char timer[6];
unsigned long int suivant;
2023-12-07 14:02:18 +01:00
2023-11-30 09:54:00 +01:00
int serpent;
2023-12-07 14:02:18 +01:00
int x=500, y=500, direction=1, t, segment=10, i;
int pos_x[60], pos_y[60], old_x[60], old_y[60];
int p, pp, pomme, pommex[5], pommey[5];
2023-12-04 17:01:52 +01:00
int fond, Nbr;
char score[4];
int go_on=1;
2023-11-30 09:59:11 +01:00
/*Fonction Principale*/
int main(){
2023-12-04 17:01:52 +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);
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();
Serpent();
Pomme();
}
2023-12-04 17:01:52 +01:00
/* fermeture de la fenêtre si ECHAP pressé*/
usleep(3000000);
EcrireTexte(000,000,"Game Over", 000);
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
}