Files
SAE11_2023/snake/time.c

71 lines
786 B
C
Raw Normal View History

2023-12-07 16:15:47 +01:00
#include <stdlib.h>
#include <stdio.h>
2023-12-10 00:36:22 +01:00
#include <graph.h>
2023-12-07 16:15:47 +01:00
2023-12-10 00:36:22 +01:00
#define CYCLE 1000000L
2023-12-07 16:15:47 +01:00
int main(void) {
2023-12-10 00:36:22 +01:00
unsigned long suivant;
2023-12-07 16:15:47 +01:00
2023-12-10 22:51:36 +01:00
/* int* time = NULL; */
/* time = malloc( sizeof(short int));
time[0] = 0;
time[1] = 0; */
2023-12-07 16:15:47 +01:00
2023-12-10 00:36:22 +01:00
suivant = Microsecondes() + CYCLE;
2023-12-07 16:15:47 +01:00
2023-12-10 22:51:36 +01:00
/*printf("%d : %d\n", &time[0],&time[1]);*/
2023-12-07 16:15:47 +01:00
2023-12-10 00:36:22 +01:00
while (1) {
2023-12-10 22:51:36 +01:00
if (Microsecondes() > suivant) {
2023-12-07 16:15:47 +01:00
2023-12-10 00:36:22 +01:00
/* une periode s'est écoulé */
/* prochaine date */
suivant = Microsecondes()+CYCLE;
2023-12-10 22:51:36 +01:00
/*time[1]++;
2023-12-07 16:15:47 +01:00
2023-12-10 22:51:36 +01:00
if ( time[1] == 60) {
2023-12-07 16:15:47 +01:00
2023-12-10 22:51:36 +01:00
time[1] = 0;
2023-12-10 00:36:22 +01:00
2023-12-10 22:51:36 +01:00
time[0] ++;
2023-12-10 00:36:22 +01:00
2023-12-10 22:51:36 +01:00
}*/
printf("%lu", Microsecondes());
2023-12-10 00:36:22 +01:00
2023-12-07 16:15:47 +01:00
}
2023-12-10 22:51:36 +01:00
/* if ( ToucheEnAttente() == 1 ) {
if (Touche() == XK_space) {
break;
}
}*/
2023-12-10 00:36:22 +01:00
2023-12-10 22:51:36 +01:00
}
2023-12-10 00:36:22 +01:00
return EXIT_SUCCESS;
2023-12-10 22:51:36 +01:00
2023-12-10 00:36:22 +01:00
}