This commit is contained in:
2024-11-23 15:47:19 +01:00
parent f46e51b907
commit e7a7a165e1

View File

@@ -5,15 +5,14 @@
#include "../include/jeu.h" #include "../include/jeu.h"
#include "../include/jeu_humain.h" #include "../include/jeu_humain.h"
#define DELAI_MS 100
void attendre(int secondes) {
time_t start_time = time(NULL);
void attendre(int delai_ms) { while(difftime(time(NULL), start_time) < secondes) {
clock_t start_time = clock(); break;
while (((clock() - start_time) * 1000) / CLOCKS_PER_SEC < delai_ms) { }
} }
}
void jouerModeHumain(struct EtatJeu *etatJeu) { void jouerModeHumain(struct EtatJeu *etatJeu) {
while (1) { while (1) {
@@ -27,12 +26,12 @@ void jouerModeHumain(struct EtatJeu *etatJeu) {
if (etatJeu->phase > 0 && !peutDeplacer(*etatJeu, etatJeu->tourJoueur)) { if (etatJeu->phase > 0 && !peutDeplacer(*etatJeu, etatJeu->tourJoueur)) {
afficherVictoire(etatJeu->tourJoueur == 1 ? 2 : 1); afficherVictoire(etatJeu->tourJoueur == 1 ? 2 : 1);
while (!SourisCliquee()) { while (!SourisCliquee()) {
attendre(DELAI_MS); attendre(1);
} }
break; break;
} }
} }
attendre(DELAI_MS); attendre(1);
} }
} }