Hi there,
First of all, I would like to thank you guys for providing this library as it really has been motivating me to work more on C++.
I'm working on a Shmup ( side scrolling shoot'em up ). And as I'm working my way up to making a suitable system for my game I'm pretty much stuck on how I should handle the input.
I know there are global methods for input and I could just write the input directly in my player class. However I rather want my player object to "register" to an input manager instead and let this manager dispatch the event to all my registered object.
The reason for this is that I might want to implement a multiplayer mechanic up to 4 players.
Two things that make it hard for me to come up with a solution:
1:with the sf::Joystick object I can see if a button is pressed, but it also demands that I specify a controller id.
2:With window.pollEvent(...) it would require me to pass the window object to my manager. However I'm not sure if this is a good idea. From what I understood pollEvent pops the event, so other events might get lost if the input manager is popping events that are of no interest.
Basically what I want to do is something like
InputManager.registerJoy(myPlayerObject, joyID);
InputManager.registerKbrd(myPlayerObject);
And let my objects implement an interface/abstract class which are called on event. something like:
void onInputEvent(Event evt){
//do magic here.
}
Now maybe I'm overlooking something that already exists in this library. But at this point I can't come up with a solution. Does anyone have suggestions?
Any help is appreciated!
Sidar