mise à jour

This commit is contained in:
2023-12-10 22:51:36 +01:00
parent 81aa9fae9b
commit eaea71caa3
5 changed files with 47 additions and 19 deletions

View File

@@ -8,6 +8,7 @@ but : run
OFILES = plateau_init.o \ OFILES = plateau_init.o \
fenetre.o \ fenetre.o \
time.o \
main.o main.o
CC = gcc CC = gcc
@@ -20,7 +21,10 @@ plateau_init.o : plateau_init.h
fenetre.o : fenetre.h plateau_init.h fenetre.o : fenetre.h plateau_init.h
main.o : main.c fenetre.h time.o : time.h
main.o : main.c fenetre.h time.h
### COMMANDES ### ### COMMANDES ###

View File

@@ -72,7 +72,7 @@ int** deplacement(int* p, int timer) {
if (TouchEnAttente() == 1) { if (TouchEnAttente() == 1) {
if (Touche() == "XK_Left") { if (Touche() == XK_Left) {
p[tete[0]][tete[1]] = 0; p[tete[0]][tete[1]] = 0;
@@ -84,7 +84,7 @@ int** deplacement(int* p, int timer) {
} }
if (Touch() == "XK_Right") { if (Touch() == XK_Right) {
p[tete[0]][tete[1]] = 0; p[tete[0]][tete[1]] = 0;
@@ -96,7 +96,7 @@ int** deplacement(int* p, int timer) {
} }
if (Touch() == "XK_Up") { if (Touch() == XK_Up") {
p[tete[0]][tete[1]] = 0; p[tete[0]][tete[1]] = 0;

View File

@@ -1,8 +1,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <graph.h>
#include "fenetre.h" #include "fenetre.h"
#include "plateau_init.h" #include "plateau_init.h"
#include <graph.h> #include "time.h"
@@ -18,9 +19,6 @@ int main(void) {
start(); start();
Touche(); Touche();

View File

@@ -11,15 +11,21 @@ int main(void) {
unsigned long suivant; unsigned long suivant;
unsigned int secondes = 0, minutes = 0; /* int* time = NULL; */
/* time = malloc( sizeof(short int));
time[0] = 0;
time[1] = 0; */
suivant = Microsecondes() + CYCLE; suivant = Microsecondes() + CYCLE;
printf("%d : %d\n", minutes, secondes); /*printf("%d : %d\n", &time[0],&time[1]);*/
while (1) { while (1) {
if (Microsecondes() > suivant) { if (Microsecondes() > suivant) {
@@ -28,17 +34,16 @@ int main(void) {
suivant = Microsecondes()+CYCLE; suivant = Microsecondes()+CYCLE;
secondes++; /*time[1]++;
if ( secondes == 60) { if ( time[1] == 60) {
secondes = 0; time[1] = 0;
minutes ++; time[0] ++;
} }*/
printf("%lu", Microsecondes());
printf("%d : %d\n", minutes,secondes);
@@ -47,8 +52,19 @@ int main(void) {
} }
/* if ( ToucheEnAttente() == 1 ) {
if (Touche() == XK_space) {
break;
}
}*/
} }
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

10
snake/time.h Normal file
View File

@@ -0,0 +1,10 @@
#ifndef TIME_H
#define TIME_H
void time(void);
#endif /* TIME_H */