How can I retrieve the object properties values from the database?

Building a small game for fun?

  • Using Java btw What is the best way to store data about the items in the game and what is the best way to retrieve it. For example creating a level using objects like land tiles. Currently my ineffective method is saving the url for the picture of the object and properties in a text file. Would it be better to use a database? If so a good example would be appreciated.

  • Answer:

    It depends somewhat on the language you are using, and the libraries/frameworks you can utilize. For instance, in Java, I might suggest using serialization, with the caveat that you might need to take care of changes in your objects between versions. Even though XML is often over-prescribed, using an XML file might not be a bad idea either. A "database" might be a little heavyweight for this, however there are some lightweight embedded databases that might be useful (SQL light and sleepycat/BDB come to mind). A plain text-file has the disadvantage that it is easier to "hack", although no save file is hack-proof, as devoted hackers can reverse engineer your game. Also, if you're on Windows, and the amount of data is small, it might be worth storing it in the registry.

Tim at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

A text file containing what each tile is. Use a 2D ArrayList of a Tile class or something to hold the data. This is just for fun, so...

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.