Jump to content

  • Log In with Google      Sign In   
  • Create Account

Organization of objects


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Oldfrith   Members   -  Reputation: 102

Like
0Likes
Like

Posted 26 November 2012 - 07:29 PM

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?

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14262

Like
0Likes
Like

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.

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
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 Krohm   Crossbones+   -  Reputation: 3249

Like
0Likes
Like

Posted 27 November 2012 - 01:27 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS