saving scores

Started by
6 comments, last by vinb 18 years, 7 months ago
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]
Advertisement
google: <fstream>

And try not to post such distractive topic names ;)
Better yet, google File Input/Output. There's probably a nice tutorial on the site.

// writing player score to fileofstream outfile("scores.txt", ios::append);outfile << player_name << " " << player_score << endl;outfile.close();// reading player scores from fileifstream infile("scores.txt", ios::in);while(!infile.eof()){    infile >> player_name >> player_score;    print(player_name);    print(player_score);}infile.close();
Author Freeworld3Dhttp://www.freeworld3d.org
no porn? wtf... LOL ;)
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.

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..
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.

This topic is closed to new replies.

Advertisement