 |
|  |
 |
|
Blake
|
 |
Brainfallocatione
Oct 2000 time: 17:24
|
|
Okay, heres a game component to design and code (or steal ).
Functions:
Manages game variables.
Loads from txt files.
Loads from compiled files.
The primary function of this class is to load&parse files, that look something like this:
code:
[Variables]
Growth = 40 #Nominal population growth ( /1000 for %age)
Growth_Per_SE = 4 #The change to growth caused by each + in SE Growth
Growth would be a variable, and the data manager would keep variables handy for other classes to get to.
And # means comment, ofcourse The word between [ ] basically indicates what to do with the following stuff, until the next [ ]
Another example would be classes
code:
[unit]
name = "Light Tank"
hitpoints = 300
range = 4
firepower = 3
speed = 10
[unit]
name = "Hover Tank"
hitpoints = 150
range = 3
firepower = 3
speed = 20
When it encounters "unit" it will know what follows is a unit defintion. However it wont have to do anything with the data, rather it'll call a function in the unit factory which will know how to extract the data it wants from the token stream, do stuff with the data (create a new unit, I should hope), then return when it hits the next [ ] or hit's an error.
However the data manager will have to provide functions to extract the tokens from the stream, for example a snippet of the factory method for a new unit might look something like this
code:
unit = new Unit;
dataman->discard("name ="); // dataman complains if doesn't find "name ="
unit->name = dataman->readString(); //complains if doesn't find a string
dataman->discard("hitpoints =");
unit->hitpoints = dataman->readInt(); //complains if it doesn't find a int
Notes:
Use c style streams, as c++ streams are really dodgy at the moment, they seem to work a different way with each version of gnu g++.
Stuff like compiled formats are very low priority.
It could be fun to have a way to register a factory method (and associated class name) with the data manager class, thus avoiding the need to change the code when adding more factory methods.
A singleton class could work well.
The format can basically be designed on the fly, however it could be worthwhile looking at how other games do. My examples look quite a bit like FreeCiv's data format.
Everything I've said or suggested is basically a suggestion, discussion of better methods is welcome.
Any volunteers?
|
|
|  |
 |
|
Blake
|
 |
Brainfallocatione
Oct 2000 time: 17:24
|
|
many-many files.
Ideally, it would be possible to choose a selection of files to load, for example a core set of rules, but then being able to load extra files, like for extra units or something. (making it particullary easy to add simple mods)
It may make sense to then compile all the rules into a single binary file (I have a few ideas on how to do that, it wont really be the data managers responsibility), because as I understand it a single large XML file would be hell slow to load, *especially* using DOM.
Basically, we want to store everything we possibly can in the data files, except save games, map data etc which should be in a binary format. Or IOW, everything that we want the players to be able to edit, for example editing the save games would not be a sensible thing for a player to do.
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:24. Apolyton Time is 00:24. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|