Thanks a lot for those detailed answers!
After reading all this, i wanted to write it down in pseudocode/snippets to see if i understood it correctly.
In short, it would work like that:
0. Check the current state
1. Check for events that cause loss of control, or modify control ( knocback, stun, during a jump, combo etc. )
2. If there is loss of control/modification, change state
3. Check for input
4. Pass the state and the input to the hero class
5. Adjust the state accordingly - e.g. if character is being knocked back, ignore the input, otherwise take normal input and set state
6. Apply logic ( move, change hp )
7. Draw frames
8. Check for expiration of states - end of knockback, landing from a jump
9. If the state has not expired, keep the state, and adjust time remaining in that state, otherwise return to default state
Rinse and repeat.
Now i have question about code, specifically code/class separation. Just gonna paste small snippets.
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Something))
input_state = x;
//repeat many times for all possible outcomes
case 1: //something that prohibits action - ignore input
case 2: // input allowed
//draw proper frame, of proper animation, depending on state
Would that be the way to do it?
Edit: Buttons are hardcoded just for now, later buttons could be changed to virtual buttons, and base controls on .ini files, like sox suggested.