Configurative properties of game objects

Hello,

I’m wondering what are the best practices to implement some XML based (I assume) configuration management for my game.

Let’s say I have a RTS-game and I have all these units, but I don’t want to create classes like LightTank, HeavyTank, MediumTank and even MotorBike and define the configuration for each of those units in the programming code.
I would rather want to create a class called Unit, and define the configurative properties for those units outside the code.

Like in a INI file I would have something like:

[LightTank]
Type=Unit
Health=300
Speed=40

Thank you very much! :slight_smile:

If you are sure you want an INI file equivilent, your simplest solution by far is java.util.Properties files. They’re almost the same and extremely easy to use. XML can at times be overkill for simple things.

If its going to be more complicated config, i.e. hiearchial then XML is the way to go. Java has built in support for processing XML in the form of a DOM compatible object tree. See DocumentBuilder and Document

You might also want to consider the conversation here: http://www.java-gaming.org/forums/index.php?topic=11158.0

Kev