I've been reading into Entity-Component-Systems, and they seem rather handy. However, I don't quite understand how input should be handled and after googling and looking thru GDSE posts, I've become even more confused. I see plenty of explanations, but no examples of how to incorporate things like an
Originally, I planned on polling for keyboard events and passing those events onto a controller. This controller would have a vector of callback functions, which could be rebound to different keys on the fly. But then I realized it doesn't translate well into a game with multiple characters, each with their own set of actions - like a fighting game, or the Megaman X games that allow you to switch between characters.
I thought that if I were to make these callback functions rather generic, so that they just change the state of the character, then have a System that consumes states for different characters to apply different results to the action (IE, the "jump" button would set the currently controlled character's state to
JUMPING. But maybe Character 1 jumps faster than Character 2, but Character 2 jumps higher). But that doesn't seem like a wise idea, because now I have a system for every state that each character could possibly have. It smells really bad, basically. And to have a character unsubscribe from one "State System" and resubscribe to another just gives me the feeling that I am not doing something right, but I am at a loss.
How should I handle input that can differ slightly from character to character? I feel like I am on the right track with having the states handle input, but I don't think that each state should have it's own system. A state should be generic and operate on many entities, not just a single instance of one!