I'm working at my first game and I've decided to build a simple component based engine. I found really useful to work in that way but I still miss some fundamentals probably.
Let say that I have a super simple game like this: A spaceship that moves where user touches/clicks the screen. Before moving the ship the user has to select it by a touch/click over the spaceship sprite and to deselect it the user has to touch/click wherever outside the sprite.
To build something like that I'd use this structure:
Spaceship Entity
|_____________ Movable Component (contains coordinates)
|_____________ Drawable Component (contains a sprite)
Rendering system:
- Check for every entities with drawable and movable component and draw
the sprite at the coordinate defined by movable component
Or something similar..
At this point I would like to add an input manager. But err... I really don't know which is the best way to attach an Input Manager in this structure! Do you think it's a good idea to create something like a Selectable component
and then create a Input System
?
The problem is that probably it would be useful to keep track of the selected object in other systems too and I suppose that this part could be managed outside the Component system.
So my question is how to deal with a behaviour that is so important and generic like user interaction in a Component based architecture. Have you had experience with this problem? Which solutions did you choose?
Edit: And in general I suppose that is a valid idea to keep track of the current selected object. Using a component based architecture how can I manage shared information?
control
component. – House Apr 25 '13 at 16:29