Users browsing this thread: 3 Guest(s)
What's the Most Efficient Way to Program This?
#2
This really depends on the language you're using, or more specifically, whether you're using an OOP language. I program in AS3, which is heavily object-oriented, and the method you're using looks horrible and messy to me. But it's quite possible that in Java or something this would be a perfectly acceptable way to do it.

Personally, I would make a base "Weapon" class, which has properties and methods that each weapon should have. In your case this would be things like "base damage", "base fort", "power bonus" (which would be 0 if there is none), etc. Then you could have "PolishedWeapon" and "DamagedWeapon" which each inherent "Weapon", and have all the little additions which Polished and Damaged weapons need. In the end you'd then make a bunch of weapons (either as subclasses or just instances, depending on your needs), with their stats safely tucked away in objects, rather than long messy arrays. This is not only more manageable to code, but makes it easier for your mind to handle as well.

That's just to give you an idea of what I'd do, depending on the game you could make it make it more complex, with more subclasses. Of course, as I said, the general way to approach this really depends on your language, the above is just what I would suggest for an greatly OOP language like AS3.
You may have a fresh start any moment you choose, for this thing that we call "failure" is not the falling down, but the staying down. -Mary Pickford
Thanked by:


Messages In This Thread
RE: What's the Most Efficient Way to Program This? - by puggsoy - 08-08-2013, 08:32 PM

Forum Jump: