Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Options_Engine/OptionsEngine.cpp
- Revision:
- 35:138ad0faa42b
- Parent:
- 26:0dc10374546f
- Child:
- 36:9f7463a65fe0
diff -r 7e03391cb8a6 -r 138ad0faa42b Options_Engine/OptionsEngine.cpp
--- a/Options_Engine/OptionsEngine.cpp Tue Apr 30 10:55:22 2019 +0000
+++ b/Options_Engine/OptionsEngine.cpp Sat May 04 18:56:38 2019 +0000
@@ -102,39 +102,59 @@
}
}
-void OptionsEngine::read_bb_high_scores(){
- std::ifstream file;
- file.open("/sd/bbhighscores.txt");
- if(!(file.is_open())){
+void OptionsEngine::read_classic_high_scores(){
+ FILE *fp;
+ fp = fopen("/sd/classichighscores.txt", "r");
+
+ if(fp == NULL){
printf("Error: Could not open file");
+ } else {
+ int i = 0;
+ rewind(fp);
+
+ while(fscanf(fp, "%d,%f", &_classic_index[i], &_classic_values[i]) != EOF){
+ i++;
+ }
+ fclose(fp);
}
- std::string nth_score;
- for(int n = 0; n < 5; n++){
- std::getline(file, nth_score);
- std::istringstream ipstream(nth_score);
- ipstream >> _bbarray[n];
+}
+
+void OptionsEngine::read_bb_high_scores(){
+ FILE *fp;
+ fp = fopen("/sd/bbhighscores.txt", "r");
+
+ if(fp == NULL){
+ printf("Error: Could not open file");
+ } else {
+ int i = 0;
+ rewind(fp);
+
+ while(fscanf(fp, "%d,%f", &_bb_index[i], &_bb_values[i]) != EOF){
+ i++;
+ }
+ fclose(fp);
}
}
void OptionsEngine::print_high_scores(N5110 &lcd){
if(_leaderboard == CLASSIC_MODE){
+ read_classic_high_scores();
lcd.printString("Classic", 21, 0);
- lcd.printString("1.", 0, 1);
- lcd.printString("2.", 0, 2);
- lcd.printString("3.", 0, 3); lcd.printString("R>", 72, 3);
- lcd.printString("4.", 0, 4);
- lcd.printString("5.", 0, 5);
-
-
+ lcd.printString("R>", 72, 3);
+ char buffer[14];
+ for(int i = 0; i < 5; i++){
+ sprintf(buffer, "%d. %.2f", _classic_index[i], _classic_values[i]);
+ lcd.printString(buffer, 0, i + 1);
+ }
}
if(_leaderboard == BRICKBREAKER_MODE){
read_bb_high_scores();
lcd.printString("Brickbreak", 12, 0);
- for (int i = 1; i < 6; i++){
- char buffer[6];
- sprintf(buffer, "%1d. %2d", i, _bbarray[i-1]);
- lcd.printString(buffer, 0, i);
+ lcd.printString("<L", 72, 3);
+ char buffer[14];
+ for(int i = 0; i < 5; i++){
+ sprintf(buffer, "%d. %.0f", _bb_index[i], _bb_values[i]);
+ lcd.printString(buffer, 0, i + 1);
}
- lcd.printString("<L", 72, 3);
}
}
\ No newline at end of file