Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

External Objects

Hi,

Just needed some info / advice / suggestions on the follwing...

I have heard that keeping most values externally (as in a file that gets read in) is the best way to go as you dont have to recompile when tweaking settings.

Along the same lines, I was thinking of expanding on this thought and make actual objects in text files.

Here is an example: (quick and dirty)

[code]
class weapon
{
public:
int range;
int damage;
}

class rifle::weapon
{
string name;
range = 15;
damage = 20;
}
[/code]

I know syntax is way off, but given as an example. :)
in any case, so say I have 20 different weapons, normally I would create 20 different classes.

This made me think, what if I want 50 different weapons, or add new weapons in the future?

So, I started to think is there a way for the game to read in a file and make these classes while the file is not EOF?

so as an example, in a text file i have:

"Rifle"
15
20

"Rocket Launcher"
8
50

would it be possible to iterate on this file to make the rifle object and a rocket launcher object and whatever else is there?

in addition, if i have 50 soldiers, 20 have rifles and the rest have various others... how would they use these objects?

Simply solved in classes by making the object for each soldier.
EX:
Rifle rifle1;
rifle1.assign (soldier1);

I know I am asking a lot, but any advice anyone can give would be greatly appreciated. (and credits will be given :) )
I have heard scripting languages (LUA / GameMonkey) could help. Is this a viable option?

Thanks in advance.

-G
=Ghost=>

Comments

Sign In or Register to comment.