Skip to content
Snippets Groups Projects
Commit 65f0e3f7 authored by vautrin33u's avatar vautrin33u
Browse files

début tri de score et tableau score

parent 72a28005
No related branches found
No related tags found
No related merge requests found
...@@ -167,4 +167,46 @@ char** init_map (){ ...@@ -167,4 +167,46 @@ char** init_map (){
} }
genere_fichier(nomFichier, tab, hauteur, largeur); genere_fichier(nomFichier, tab, hauteur, largeur);
return tab; return tab;
}
char* recuperer_highscore(const char* nomFichier){
//Récupère le tableau des scores et le retransmets
char* tableau[10];
//Initialisation du tableau
for (int i=0; i<10; i++){
tableau[i] = NULL;
}
FILE* fichier = NULL;
fichier = fopen(nomFichier, "r");
if (fichier == NULL){
int i=0;
char c = '\0';
while ((c = fgetc(fichier)) != NULL){
printf("%s", tableau[i]);
i++;
}
}
return tableau;
}
void trier_highscore (char* highscore, int score_entrant){
//Trie les scores du plus grand au plus petit
//traduction char->int
int* tab[10];
for (int i=0; i<10; i++){
tab[i] = atoi(highscore[i]);
}
//trie
//traduction int->char
for (int i=0; i<10; i++){
sprintf(highscore[i], "%d", tab[i]);
}
}
void ecrire_highscore(const char* nomFichier, char* highscore){
//ecrire le tableau de score trié et à jour dans le bon fichier
} }
\ No newline at end of file
...@@ -62,4 +62,28 @@ char** lire_fichier (const char* nomFichier); ...@@ -62,4 +62,28 @@ char** lire_fichier (const char* nomFichier);
* */ * */
void genere_fichier (const char* nomFichier, char** source, int ligne, int colonne); void genere_fichier (const char* nomFichier, char** source, int ligne, int colonne);
/**
* @brief écupère le tableau des scores et le retransmets
*
* @param nomFichier Adresse du fichier
* @return char* tableau de score
*/
char* recuperer_highscore(const char* nomFichier);
/**
* @brief Trie les scores du plus grand au plus petit
*
* @param highscore tableau de scores
* @param score_entrant score de la partie actuelle
*/
void trier_highscore (char* highscore, int score_entrant);
/**
* @brief ecrire le tableau de score trié et à jour dans le bon fichier
*
* @param nomFichier Adresse du fichier de score
*/
void ecrire_highscore(const char* nomFichier, char* highscore);
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment