Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. void GameManager::printHighscores() {
  2. clrscr();
  3. gotoxy(5, 2);
  4. textcolor(10);
  5.  
  6. cout << "GAME OVER!" << endl;
  7. cout << "Score is: "<< formation->getScore();
  8.  
  9. Score* highScores[5];
  10. scoreManager->getHighScores(highScores);
  11. bool isHighScore = false;
  12. for(int i = 0; i < 5 && !isHighScore; i++) {
  13. if (highScores[i]->score <= formation->getScore()) {
  14. isHighScore = true;
  15. }
  16. }
  17.  
  18. char name[30];
  19.  
  20. if (isHighScore) {
  21. cout << "You make it to the highscores! Please Enter your name:" << endl;
  22. gets(name);
  23. Score* newScore = new Score();
  24. strcpy(newScore->name, name);
  25. newScore->score = formation->getScore();
  26.  
  27. scoreManager->addScore(highScores, newScore, highScores);
  28. }
  29.  
  30. scoreManager->getHighScores(highScores);
  31.  
  32. for (int i = 0; i < 5; i++) {
  33. textcolor(i +2);
  34. puts(highScores[i]->name);
  35. //cout << "......" << highScores[i].score << endl;
  36.  
  37. }
  38.  
  39. getchar();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement