help

Started by
1 comment, last by jbadams 18 years, 8 months ago
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)
Advertisement
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();}
-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.

- Jason Astle-Adams

This topic is closed to new replies.

Advertisement