It does not matter how we want to control the game; it can always be abstracted as a two-axis joystick and a button to fire. For other games this could be different, but you should always be able to extract basic actions from the user and create an InputController
that handles them. The InputController
we are building is useful for any game that uses directional control.
We are going to consider a normalized horizontal and vertical axis as an input (going from -1 to 1). In the case of a controller that does not have a range, we will just set it to the maximum. This will allow us to handle user input with precision when the type of input allows us to, as is the case with virtual and real joysticks as well as with sensors.
Just as a reminder, the coordinates on a computer screen have [0,0] in the top-left corner and go positive towards to the right and down. The...