Skip to main content
GameDev.net gamedev.net
🔒 Locked

Organization of objects

Started by Oldfrith Nov 27, 2012 at 1:29 AM 1 replies 1.4k views
Original Post
Oldfrith
Oldfrith
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?
L. Spiro
L. Spiro
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
I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid
Krohm
Krohm
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.
Previously "Krohm"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.