我在写一个基于多人C++的游戏。什么配置文件格式允许包含其他文件和设置的继承?
我需要一个灵活的文件格式来存储关于游戏角色的信息。
游戏charactors往往不能共享相同的属性,或使用basew
例如:
,让我做一些像这样的格式:
#include "standardsettings.config"
//include other files which this file
//then changes
FastSpaceship:
Speed: 10 //pixels/sec
Rotation: 5 //deg/sec
MotherShip : FastSpaceship //inherits all the settings of the Spaceship ship
ShieldRecharge: 4
WeaponA [ power:10,
range:20,
style:fireball]
SlowMotherShip : MotherShip //inherits all the settings of the monther ship
Speed: 4 // override speed
我我一直在寻找一种预先存在的格式,可以完成所有这些,或者是相似的,但是没有运气。我很想不要重新发明轮子,除非必须,所以我想知道是否有人知道任何支持这些功能的良好配置文件格式
如何将与包括其他文件,这项工作。我想要的东西有点像CSS。 我真的不希望有制定出所有包含在用户代码继承(我想在图书馆做这个工作) 因此我可以键入类似; rotation = lookup(“SlowMotherShip.Rotation”);并且它会计算出旋转值为5. – Kingsley 2009-08-05 13:32:54
那么我想我没有很好的答案。我不知道任何知道对象间层次关系的文件格式库。这并不是说它不存在(开源世界远远大于我的经验)。 虽然我写过类似的东西。格式很简单,解析器只知道如何处理一些像“继承”(IIRC,我们使用关键字“super”)的“关键字”。 – moswald 2009-08-05 14:11:21