Skip to content

Instantly share code, notes, and snippets.

@kawzar
Created April 14, 2019 18:31
Show Gist options
  • Save kawzar/7b60f3274e58f089ecf5c7abe2b72b9c to your computer and use it in GitHub Desktop.
Save kawzar/7b60f3274e58f089ecf5c7abe2b72b9c to your computer and use it in GitHub Desktop.
void GameManager::printHighscores() {
clrscr();
gotoxy(5, 2);
textcolor(10);
cout << "GAME OVER!" << endl;
cout << "Score is: "<< formation->getScore();
Score* highScores[5];
scoreManager->getHighScores(highScores);
bool isHighScore = false;
for(int i = 0; i < 5 && !isHighScore; i++) {
if (highScores[i]->score <= formation->getScore()) {
isHighScore = true;
}
}
char name[30];
if (isHighScore) {
cout << "You make it to the highscores! Please Enter your name:" << endl;
gets(name);
Score* newScore = new Score();
strcpy(newScore->name, name);
newScore->score = formation->getScore();
scoreManager->addScore(highScores, newScore, highScores);
}
scoreManager->getHighScores(highScores);
for (int i = 0; i < 5; i++) {
textcolor(i +2);
puts(highScores[i]->name);
//cout << "......" << highScores[i].score << endl;
}
getchar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment