Public Group

# help

This topic is 4837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

in my game of tetris i want to be able to show the lowest, highest and average that the gamer gets, how could i achieve this eg(how would i make it so it knows what the highest score is and what the lowest score is, and average as well)

##### Share on other sites
Pseudocode:
int lowestScore = 5000;int highestScore = 0;...if (gameOver){  if (score < lowestScore)  {    lowestScore = score;  }  if (score > highestScore)  {    highestScore = score;  }  runningAverage_Num += scores;  ++gamesPlayed;  ...}...if (quit || ShowScoreTable){  averageScore = runningAverage_Num / gamesPlayed;  ShowHighScore();}

##### Share on other sites
-Store the lowest score. If the player gets a lower score at any point, then store that instead.
-Store the highest score. If the player gets a higher score at any point, then store that instead.
-Store all the players scores, and average them between every game. Store the result.
-If you want this to persist over multiple play sessions, you'll need to write these values out to a file when exiting and load them up when initialising. I wouldn't suggest keeping all of the players scores for averaging purposes if you do this though; a good alternative would be to keep 5-10 or so (high scores list?) and use those, or alternately only write out only the average with the lowest and highest, and use it along with the scores of the next play session.

Display those values. Oluseyi's pseudocode example should give you a good idea of how to that. See what you can come up with, and come back if you need more help.

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633417
• Total Posts
3011782
• ### Who's Online (See full list)

There are no registered users currently online

×