Advertisement Jump to content
Sign in to follow this  
fearfactory

help

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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();
}

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!