Jump to content
  • Advertisement
Sign in to follow this  
fearfactory

saving scores

This topic is 4683 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

again i need advice for me game of tetris i want the player to be able to save their scores to a text file, but i have zip idea of how to do that. any help is apreciated [Edited by - Sneftel on August 29, 2005 3:22:42 PM]

Share this post


Link to post
Share on other sites
Advertisement



// writing player score to file
ofstream outfile("scores.txt", ios::append);
outfile << player_name << " " << player_score << endl;
outfile.close();

// reading player scores from file
ifstream infile("scores.txt", ios::in);

while(!infile.eof())
{
infile >> player_name >> player_score;
print(player_name);
print(player_score);
}

infile.close();


Share this post


Link to post
Share on other sites
Quote:
Original post by fearfactory
but i have zip idea of how to do that.

A zip file seems to be a rather complicated solution ;)

~sorry, couldn't resist.

By the way, insead of a text file, you might consider an XML file as it allows for other possibilities like posting player results to the web and stuff like that. I don't know if your game is meant to do stuff like that, but it might make for a fun alternative to explore.

Share this post


Link to post
Share on other sites
Quote:
Original post by vinb
By the way, insead of a text file, you might consider an XML file as it allows for other possibilities like posting player results to the web and stuff like that. I don't know if your game is meant to do stuff like that, but it might make for a fun alternative to explore.
Still, human readable and easily editable is generally the *last* thing you want your highscore file to be..

Share this post


Link to post
Share on other sites
Quote:
Still, human readable and easily editable is generally the *last* thing you want your highscore file to be..


Your not suggesting that people would cheat!? Your point is well taken.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!