我在寫一個基於多人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