Friday, January 30, 2009

File formats and scripting - XML

I think I want to use XML to create the quests and bulk of the game. I wrote up a basic idea of what I think an xml file for the game would look like.
<game>

<quest type=" ">
 <id>  </id>
 <title>   </title>
 <description>  </description>
 <incomplete>  </incomplete>
 <complete>  </complete>
 <failure>  </failure>
 <npcid>  </npcid>
 <solution>
  <killnpcid>  </killnpcid>
  <finditemid>  </finditemid>
  <savenpcid>  </savenpcid>
 </solution>
 <reward>
  <giveitemid>  </giveitemid>
 </reward>
</quest>

<npc x=" " y=" ">
 <id>  </id>
 <name>  </name>
 <sprite>  </sprite>
 <avatar>  </avatar>
 <talk>  </talk>
 <alignment>  </alignment>
 <movement>  </movement>
 <health>  </health>
 <inventory>
  <itemid>  </itemid>
  <itemid>  </itemid>
 </inventory>
</npc>

<item x=" " y=" ">
 <id>  </id>
 <type>  </type>
 <name>  </name>
 <sprite>  </sprite>
 <description>  </description>
 <quantity>  </quantity>
 <damage>  </damage>
 <heal>  </heal>
</item>

</game>

After some searching, it seemed that TinyXML was the most popular for games. But alas, I am coding in C, not C++ so I couldnt really use it. I looked around a bit more and found ezXML. Its written in C and its very easy to use. I loaded it up and got it working straight away. I wrote an app that reads in the file and counts how many there are of each type. It then allocates memory to store each in a structure and loads them in.

No comments:

Post a Comment