You would set the player to idle at first, when a key is pressed set it moving, say a spacebar jumping then falling , no movement idle
the switch(statevar) executes the case statement that its value is, in that case statement you determine other states that can be from the state it is in
the movement code just checks if a key is pressed and assigns it to a var, no where are you setting the state or even doing anything with the vars that check for movement
there is no logic flow
state is a variable best to use a string like "RUN", "JUMP", "FLY" otherwise your dealing with 0,1,2,3 which can get cryptic
not a boolean or you just have a boolean, and you dont set states to true or false, that is not a state machine
the switch statement will determine which case statement it needs to execute run it and exit
if you do this there is no need for enums as the name of the state is right in the case statement and logic code can be easily modified
but that state has to have a logical flow to another state, draw the logic flow out out paper and it will make it much more easier to code
state = "SWIM";
step
switch(state)
case "punch": do the punch routine when done back to idle or blackeye..lol
case "run": move the player then change the state to idle when the key is let up
i think you are just trying to overcomplicate the player
i would put all the movements on an input controller object
then all the player has to process is its state and draw the matching animations
or just make a state machine object that only handles the state, less for the player object to process
each enemy can be at a state at a different time so you would put the enemy state machine on the parent enemy, "Biting", "Growling",