I am working on a small online game where you need to store reasonable information about many (100+) different game objects.
I am trying to decide whether this data should be generated by code or stored in some kind of configuration file.
The approach to data generation will be similar to (in java-ish pseudo-code):
(within a set of functions executed once at program startup)
....
grass=new GameObject();
grass.inheritProperties(generic_terrain);
grass.set(NAME,grass);
grass.set(MOVEABLE,true);
grass.set(MOVECOST,10);
grass.set(IMAGE_INDEX,1);
....
While the configuration file approach probably just uses an XML type format, for example.
(within terrain.xml file)
....
<terrain name="grass">
<inherit class="generic_terrain"/>
<property key="NAME" value="grass"/>
<property key="MOVABLE" value="true"/>
<property key="MOVECOST" value="10"/>
<property key="IMAGE_INDEX" value="1"/>
</terrain>
....
Some important points:
- This information is always static. The game is completed (i.e. no change at runtime)
- Property names (NAME, MOVECOST, etc.) are a relatively small list, but additional ones can be added over time.
- ,
(.
).
- (, / ).
- "" , .. , generic_terrain, /.
? , ?