Sign in to follow this  
Followers 0
Oldfrith

Organization of objects

2 posts in this topic

I am beginning to start writing an RPG. I have run into the problem of organizing the weapons and the like. I want to organize it by type of weapon (bow, spike, etc.) and level (lvl1, lvl2). Any suggestions?

Should I use a series of arrays to do this, or structs, or objects?
0

Share this post


Link to post
Share on other sites
It needs to be as data-driven as possible. Generally this would mean loading actual files that contain the data for each weapon, but for simple or solo projects you could just make a static const STRUCT array inside the code—just as easy to update and maintain but no loading.

Weapon types would be enumerated, and the data will just fit inside a structure of your own creation.

[CODE]
static const LS_WEAPONS g_wWeapons[] = {
{ "Cool Tiger", LS_BOW_TYPE, 46.0f, 16.0f },
{ "Cool Bear", LS_SPIKE_TYPE, 48.0f, 9.0f },
etc.
};
[/CODE]


L. Spiro Edited by L. Spiro
0

Share this post


Link to post
Share on other sites
[quote name='Oldfrith' timestamp='1353979748' post='5004374']Should I use a series of arrays to do this, or structs, or objects?[/quote]
I suggest to get a better grasp of what you're talking about. As a start, you cannot use "structs or objects" as an object is an instance of a class/struct. Similarly, if the choice of container is a concern, you're probably not ready to do that... but I guess you have to start experimenting somewhere so...
[quote name='Oldfrith' timestamp='1353979748' post='5004374']
I am beginning to start writing an RPG. I have run into the problem of organizing the weapons and the like. I want to organize it by type of weapon (bow, spike, etc.) and level (lvl1, lvl2). Any suggestions?[/quote]
Yes. First start designing what each thing is. For example, what is a level? Is it the level of character to be used or just a monicker for easier recognition? What about prerequisites and such?
Me and a friend of mine worked on a simple MUD years ago. In the end, it was all strings as enumerating and matching the various types was deemed too complex.
I actually have the required machinery available (with a lot of hours of testing) but I still think doing everything by string matching is not so bad.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0