So I have this function GetInput(KeyboardState prevKeyboardState)
and it returns a Vector2 of a whichDirection variable.
and I assign it to direction = GetInput(prevKeyboardState)
but I also use this same function to check which direction my toon is facing when he's done walking ....
I'll just show you the function.
public Vector2 GetInput(KeyboardState prevKeyboardState)
{
currentKeyboardState = Keyboard.GetState();
if (currentKeyboardState.IsKeyDown(Keys.Right))
whichDirection = new Vector2(MOVE_RIGHT, 0);
if (currentKeyboardState.IsKeyDown(Keys.Left))
whichDirection = new Vector2(MOVE_LEFT, 0);
if (!currentKeyboardState.IsKeyDown(Keys.Left) && !currentKeyboardState.IsKeyDown(Keys.Right))
whichDirection = Vector2.Zero;
if (prevKeyboardState.IsKeyDown(Keys.Left))
currentState = State.FacingLeft;
if (prevKeyboardState.IsKeyDown(Keys.Right))
currentState = State.FacingRight;
return whichDirection;
}
So my issue is that to get prevKeyboardState, I have to declare it after I make a call to this function, but in my code I use this function again to discover which direction my toon is facing. But I call it like.
GetInput(prevKeyboardState)
So my question is, is that bad design? To not have the returned value "whichDirection" go anywhere? Fixing that would be easy... I know this, but I'm wondering if that is an improper way to use a return function.