3 Replies - 328 Views - Last Post: 13 June 2013 - 08:21 AM Rate Topic: -----

#1 squarepenguin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 16-May 12

XML or custom config files to load game data?

Posted 11 June 2013 - 04:07 PM

Greetings fellow persons,

In short:

this...
#123
name:                 dirt
mass:                 2210
tensile-strength:     4000
compressive-strength: 16000
flash-point:          193

#124
name:                 sand
mass:                 3100
tensile-strength:     2100
compressive-strength: 33100
flash-point:          621
or this...
<?xml version="1.0" encoding="UTF-8" ?>
<block id="123">
 <name="dirt"/>
 <mass="2210"/>
 <tensile-strength="4000"/>
 <compressive-strength="16000"/>
 <flash-point="193"/>
</block>
<block id="124">
 <name="sand"/>
 <mass="2210"/>
 <tensile-strength="2100"/>
 <compressive-strength="33100"/>
 <flash-point="621"/>
</block>
and why?


To elaborate: imagine I'm writing a minecraft-clone with physics. There are a limited ammount (say 256) of block-types which are read from a file.
class Block{
    /* ... */
private:
    static Block blocktypes[256];
    const unsigned
        mass,
        relative_motion,
        flexibility,
        compressive_strength,
        tensive_strength,
        smoothing_factor;
    const string name;
};


Is This A Good Question/Topic? 0
  • +

Replies To: XML or custom config files to load game data?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5507
  • View blog
  • Posts: 11,808
  • Joined: 02-June 10

Re: XML or custom config files to load game data?

Posted 12 June 2013 - 07:14 AM

From my FAQ list

[*]Q: ... save data, save properties, save environmental variables, serialize my data/class?
A:
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9187
  • View blog
  • Posts: 34,489
  • Joined: 12-June 08

Re: XML or custom config files to load game data?

Posted 12 June 2013 - 07:20 AM

Typically I would roll XML just because it is more descriptive, but depending on the language, the setup, and other factors you can do it the first way as well.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: XML or custom config files to load game data?

Posted 13 June 2013 - 08:21 AM

XML is pretty standard for passing around config settings in games. Another option is JSON if you are so inclined.

I use TinyXML for my personal projects.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1