Sunday, August 2, 2009

How do I make a java rpg save option?

I'm making an rpg in java but I don't know how to make an option that saves the progress. Please be descriptive so I can understand because I am pretty new to Java. Please don't answer saying how another programming language is better.

How do I make a java rpg save option?
A quick and dirty way is to create a "GameState" object that holds all the other necessary objecst, and then save them to a file using serialization (java.io.ObjectOutputStream/ObjectInputS... See the Java Tutorial.





You can also write your GameState object as a JavaBean and use the XML serialization for beans to save to an XML file.





Later, you will probably want to store the information in a more flexible fashion, probably using either an embedded or separate-running RDBMS. Take a look at either Derby (comes with JDK) or HSQLDB.





HTH


No comments:

Post a Comment