Jump to content
  • Advertisement
Sign in to follow this  
Oldfrith

Organization of objects

This topic is 2086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.


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.
};



L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites
Should I use a series of arrays to do this, or structs, or objects?

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...

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?

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!