I was going through my game setup, and I started changing more things to be better down the road. For example, when an “item” was picked up/ran into/collided, I wanted to run a onCollision() method. The problem that occured throught this is I required certain interfaces to have methods that didn’t really make sense.
So the question is pretty simple I guess. I know inheritance can be set up different ways, but I’m running into a problem with “creatures” and when to use an interface. I guess, just can someone give me some advice on how to make this system better.
Current Setup
Tile Interface represents creatures/blocks
Entity represents any items/objects being fired as projectiles
Creature is an object (should be abstract but eh)
AttackableTile implements MoveableTile
MoveableTile implements Tile
MoveableEntity implements Entity
Creature implements AttackableTile
Bullet extends Projectile implements MoveableEntity
Now the problem…
Rifle (First weapon im making)
Rifle extends AbstractShootableWeapon implements ShootableWeapon
AbstractShootableWeapon extends AbstractWeapon
So if I wanted to always take an input of a projectile (some interface that has damage), have a weapon that may not be able to shoot, but also weapons that must be able to shoot, and be able to access all projectiles (like through parameters), and all weapons (through parameters), what would be a better setup?
Point is, if I wanted to have a weapon that was melee only, and another that was shooting only, what’s the best way of using an interface for this?
Also, if I wanted to have something (may not be a creature) that can shoot, but may not have health, but always can take damage. I don’t know, I just ended up adding a takedamage() method to MoveableEntity cause that’s how I’m passing the shooter and hit objects through my bullet/gun.
If that made any sense, does anyone have advice, or should i just yolo it and make moveableEntity have a bunch of stuff? I just want to do everything in a good way.