ID:43919
 
Keywords: programming
I'm working on some Java stuff at the moment, but I have a question regarding best OOP practise.
Basically, I have a set of objects that look kind of like this:
Object - Java base class
    Drawable - Object which is added to the draw loop of the GameEngine.
        Actor - Object capable of receiving input
            Player - Object which basically just moves around with the arrow keys (at the moment)
        StaticBullet - Object which is responsible for the spinning bullet effect seen in my previous demo.

    JGEngine - JGame engine class
        GameEngine - My base engine class
            MyGame - My extension of the engine which initialises things like player objects.


My question is this: given that the SpinningBullet class will primarily take instruction from the Player object, should it be a Player variable or a MyGame variable? On the one hand, there may be multiple Players (e.g. in a multiplayer game) so it would make sense that it should be contained by the game session rather than the actual player, but on the other hand it will be the Player object which sends it instructions on when to animate and how many bullets to display.
If it'd have anything to do with specific players (such as showing a different kind of shell if they're using a pistol or a shotgun), I'd have it belong to each individual player.

I, er, think. Just realised this is a few days old: what did you go with in the end?
I still haven't decided, although since I could leave it null for non-local Player objects, I'm inclined to have it as a Player variable. I'll probably have to rewrite the player input processing mechanism at some point to efficiently use input from a non local source (i.e. multiplayerness) but I'll cross that bridge when I come to it.