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?
2 replies to this topic
Sponsor:
#2 Crossbones+ - Reputation: 5336
Posted 26 November 2012 - 08:52 PM
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.
L. Spiro
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, 26 November 2012 - 08:53 PM.
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums
#3 GDNet+ - Reputation: 1813
Posted 27 November 2012 - 01:27 AM
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...Should I use a series of arrays to do this, or structs, or objects?
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?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?
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.






