Saving an instance of a game in java

Started by
2 comments, last by scrotumface 14 years, 6 months ago
I am not sure how basic this is, but how can a game be saved in java. I have a tic tac toe game, and want the player be able to save the exact game they are on and all their statistics in a database. So when they start the game again, it allows them to load a game using a password.
Advertisement
Are you sure you want to be able to save/load using a password? It is rather cumbersome to write passwords down on paper for saving, you can lose it or your dog cam eat it etc.
It is much easier to save the state in the traditional way, e.g player gives a name to a save file and then you he can choose one of them for loading.
For the actual saving/loading part, you can use the Serializable interface and ObjectOutputStream to export your game state into a file.
Quote:Original post by Momoko_Fan
Are you sure you want to be able to save/load using a password? It is rather cumbersome to write passwords down on paper for saving, you can lose it or your dog cam eat it etc.
It is much easier to save the state in the traditional way, e.g player gives a name to a save file and then you he can choose one of them for loading.
For the actual saving/loading part, you can use the Serializable interface and ObjectOutputStream to export your game state into a file.


Yeah, the password idea, was just so that players can have a kind of account on the database, and load it whenever, and all their statistics will be loaded, the profile will be loaded.

But yeah, the traditional way is okey.

I will look at those 2 you mentioned. Are they all that is needed, and for loading?
Thanks, found a nice tutorial

http://forum.codecall.net/java-tutorials/7817-tutorial-java-serialization.html

This topic is closed to new replies.

Advertisement