diff options
Diffstat (limited to 'src/title.c')
-rw-r--r-- | src/title.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/title.c b/src/title.c index 04cf0ca..501b3ad 100644 --- a/src/title.c +++ b/src/title.c @@ -1,5 +1,46 @@ #include "pong.h" +static struct { + int Score; + char *Name; +}Leaderboard[10]; + +static void order_leaderboard() { + int *Score; + bool Parsing = true; + + //Load leaderboard file. + char *LeaderboardDirectory = SDL_GetPrefPath("iotib", "Pong"); + char LeaderboardFilePath[8192]; + snprintf(LeaderboardFilePath, sizeof(LeaderboardFilePath), "%s/leaderboard.txt", LeaderboardDirectory); + FILE *LeaderboardFile; + if ((LeaderboardFile = fopen(LeaderboardFilePath, "r")) == NULL) { + return; + } + int Count = 0; + for(int i = 0; feof(LeaderboardFile); i++) { + Count++; + Score = malloc(Count*sizeof(int)); + if(Score == NULL) { + fprintf(stderr, "Failed to load data from leaderboards.txt\n"); + free(Score); + return; + } + fscanf(LeaderboardFile, "%d", &Score[i]); + } + int TopSpot = 0; + //int Result = 0; + //char *ResultName = NULL; + //int OldResults[sizeof(Score];) + //while(Parsing == true) { + for(int a = 0; a <= Count; a++) { + + } + TopSpot += 1; + //} + return; +} + static void settings(Camera2D *MainCamera, Mix_Music *TitleScreenMusic) { bool SettingsGoing = true; int MusicBarY = 50; @@ -137,6 +178,9 @@ int title_screen() { MainCamera.target = (Vector2){0,0}; MainCamera.rotation = 0.0f; + // Load leaderboard + //order_leaderboard(); + bool TitleScreenGoing = true; int Choice = 0; |