This site requires JavaScript, please enable it in your browser!
Greenfoot back
Razzo
Razzo wrote ...

2012/10/14

Best way to implement Weapons.

Razzo Razzo

2012/10/14

#
I'm wanting to make my Weapon system smooth yet easily added. I could make tons of different classes for each weapon, but that would be inefficient. Would making a weapon class be suitable, then adding the "bonus"'s of each weapon as variables for each object? Then apply to each player? Because I want all my weapons to have somewhat random bonus's such as "Damage" and pick an image randomly from an array.. The only problem is that I have some weapons that are "throwable" Basicly Ranged weapons such as a Boomerang, which follows different rules (Arcs).. How would I implement this effieciently? tl;dr- I want Weapons to be effiecient and not have their seperate classes, but I have a few different types of weapons, Ranged and Melee, Melee is all the sameish Ranged follows specific rules, Such as Movement paths.
SPower SPower

2012/10/14

#
Actually, creating multiple classes for multiple weapons is the best object orientation: each weapon has it's own properties, and a class is meant to reflect that. And it wouldn't be much more effiecient too ;)
Razzo Razzo

2012/10/14

#
But i'm talking about 100's of weapons with different stats,
Razzo Razzo

2012/10/14

#
Okay. I have a class "Shuriken", In the Arraylist "Inventory" I have a Shuriken object. But everytime I "shoot" I want to make a new Object of Shuriken (Or whatever else is selected in the Arraylist); How should I go about doing this?
Razzo Razzo

2012/10/14

#
I could just do "If instanceof object" Lots of times, But that would be ineffecient and isnt very practical. How could I make it so I can add a new Object of that Type!
Razzo Razzo

2012/10/14

#
Bump. Anybody? What i'm looking for is to make a new instance of a already declared object wihout changing the declared object.
MatheMagician MatheMagician

2012/10/14

#
You could create a couple classes for the several types of weapons and then store variables like "deadliness", "range"m, and such, then change those variables with your powerups and such.
Razzo Razzo

2012/10/14

#
I think i will do that! Probably! thanks
You need to login to post a reply.