1 hour ago, Seer said:
I'm sorry but no, I don't really follow you.
You seem to have noticed you had a problem, and then jumped to a solution called "Controller", and then got quite stuck. Basically you now have a number of empty boxes with labels like "Input handler" and "game object", and "controller", but what to put where?
To solve that blockage, you should analyze what (computation) steps happen exactly from input to a moving player. What I mean, what are the elementary steps, that must happen from getting keyboard events to getting the player to move correctly, no matter how many boxes you have, and where you put them (that is, independent of any implementation consideration).
In my experience that works best if you don't have an implementation solution in mind, since that imposes a structure that you consciously or unconsciously also add to the equation. Your efforts to try and fill that structure and at the same time inventing what the elementary steps are, is a very hard problem. Stop doing that. Drop the boxes, in fact throw away your entire program. Imagine you start a new program, an ideal one, where anything is possible.
So the question becomes: "In an ideal world, given keyboard events as you get them, and a player that moves like you want it to move, what are the computation steps (and in which order should they be applied), such that you get the desired effect to process keyboard input?"
That's the question I tried to answer first, and it ended with 4 pieces, A to D. Maybe my pieces are wrong, or in the wrong order, but you are the better judge there.
But in essence, no matter how you organize your code, those 4 pieces are (I think) what must be done at all times, in that order.
Now you go back to your boxes. Your problem is much simpler now. You have a number of boxes, you have a number of computation steps that must be performed in a particular order, just assign all steps to some box (invent more boxes if needed or throw away boxes that you don't need). After you did that, you know what to program where.
2 hours ago, Seer said:
In a solution of yours for a problem like this, do states ever come into the equation? Are they suitable in some way, on some level, even if perhaps not at the object level?
Oh sure, you also already had them, you just named them "flags". You can see each combination of values of the flags as a state. When you change a flag, you would jump to a different state. "states" only means you have special behavior based on the state (you do do X in state A, and Y in state B). Whether you select that special behavior X or Y because you compute it in a State object A or B, or you select that behavior because of some flag values makes no difference.
In this case I would do conversion C from key-events to player actions probably in a state machine (although I haven't yet found a nice way to write a state machine in a generic programming language).
2 hours ago, Seer said:
A thought, and probably not a well formed one, for a solution has occurred to me in which some sort of Event types would be generated depending on the value of keycode.
I proposed that too, in 2 steps. Step A converts from numeric key values to "up-pressed", "down-released", "shoot-pressed" etc events, step C converts those events to actions that the player (piece D) understands.
The reason to make that 2 steps is that C may or may not be specific to the player (depending on how you want keyboard control to work on different things you can control).
2 hours ago, Seer said:
That's as far as that idea goes. I don't know how it would be implemented, if it would even be possible to.
However, as an idea, does it sound plausible or is it far fetched?
It sounds like you want to do piece A, and then B distributes to all game objects?
If you swap B and C, then from A you get eg "shoot-released" like events, C converts that to player actions, and then B distributes that to one (or all) game objects?
See how simple it becomes if you have a list of essential elementary steps that you must do? Swap the order, change a function, and you get completely different options.
If you start too early thinking in terms of classes and objects where to put them and how to keep them generic and expandable and all that, you're unconsciously blocking a lot of options, and it's much harder to reach that clean sequence of steps where you make the true decision how processing is done (the objects are basically just wrapping around the processing structure, they don't affect the behavior itself).
2 hours ago, Seer said:
It would be very helpful if concrete examples of how to handle input in a correct manner could be provided. Remember, we're not dealing with the totally abstract here. I need to know a good way to get from the starting platform A which is the InputProcessor and its keyDown(int keycode), keyUp(int keycode) methods to B which is the Player
In my pieces, I inserted two more processing steps, so your B ended at D in my case. My step C is the "flags" thingie you have now to convert from key events to player actions, except it's coded as a separate object, so you can change or re-use it. My step B transfers the key-events from A to C, which I am not sure of how that exists (or even if it exists) in your code.
The problem with examples is that you're then basically copying inventions that someone already invented and published. That works for common problems, eg you don't invent common algorithms like A* or Bresenham. Instead you read how it works, you read an example, and then you code it.
This approach fails horribly as soon as you move into new territory, or unpublished territory (or published but not-findable teritory). That happens as soon as you go down into enough detail, where your combination of elements, and your ideas of what should exactly happen, becomes a unique combination. In such a case, there are no examples, and you have to work out how to solve the problem yourself. How to do that is also valuable experience that you must learn to become a successful programmer.