SAE11_2023/JEUX_SERPENT/main.c

67 lines
1.4 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[2400], pos_y[2400], old_x[2400], old_y[2400];
2023-12-07 14:02:18 +01:00
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-12-10 13:11:43 +01:00
int go_menu=1;
int t2;
int initialiser=0;
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);
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-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;
/*case XK_r :
system("make run");
sleep(1);
FermerGraphique();
return EXIT_SUCCESS; */
}
}
}
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
}