954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Data storage method

Hello everyone,

I'm a java programmer writing a half graphical half text rpg. For the moment I read my data from text files, e.g.
Enemies.txt

id
name
hp

and so forth. However, I want to make it a little more clear to handle, as in a database format. I can work with MySQL, but I want all the data to be on the end-user's computer, so without having to connect to the server database.

The only other thing I can think of is Excel, but I'm wondering if there aren't any other alternatives. If you know how real games used to do it, it would be really helpful.

Many thanks,
Aviras.

Aviras
Junior Poster in Training
82 posts since Jul 2008
Reputation Points: 24
Solved Threads: 8
 

Hello everyone,

I'm a java programmer writing a half graphical half text rpg. For the moment I read my data from text files, e.g. Enemies.txt

id name hp

and so forth. However, I want to make it a little more clear to handle, as in a database format. I can work with MySQL, but I want all the data to be on the end-user's computer, so without having to connect to the server database.

The only other thing I can think of is Excel, but I'm wondering if there aren't any other alternatives. If you know how real games used to do it, it would be really helpful.

I'd avoid Excel; that's a nightmare waiting to happen.

A proper database might be overkill, though, especially if your data are simple. Does "clear to handle" mean you want it to be human-readable and editable, or are you referring to making it easier for your code to load stuff in? Or is it a balance of the two?

As a step up from plain text, XML might be a good choice for you. It's structured and well-supported by standard libraries, so it helps the machines, but it's also still text, so it's still easy enough to edit by hand.

JSON is another option for text-based structured data.

If you really want a local-only database, I recommend SQLite . It's been widely adopted for use by Web applications and in embedded systems. I haven't used it from Java myself, but there are a few libraries out there--for example, SqliteJDBC .

gusano79
Posting Pro
521 posts since May 2004
Reputation Points: 182
Solved Threads: 77
 

The main reason would be human-readable as the coding part would be rather easy for every option. With using text files it just starts to be a bit messy to look up stuff, perhaps change it, when you have objects with about 8 parameters. Thereby it would be easier on the eyes and a more efficient way of working/editing to have a mysql kind of way of presenting data.

I don't know much about XML, I do know html, but at the moment i'm looking into it, and I've read some really good things about JSON, thanks a lot for the tip!

Aviras
Junior Poster in Training
82 posts since Jul 2008
Reputation Points: 24
Solved Threads: 8
 

UPDATE: In combination with using XML files, I found something about JAXB, which has a feature called unmarshalling, which makes a java object from an XML file, which is basically what I need. Since it's late however, I'll post how it went.

As a plus, it's embedded in JDK1.6.

Aviras
Junior Poster in Training
82 posts since Jul 2008
Reputation Points: 24
Solved Threads: 8
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: