Adding functionality to the player
Of course, the player can’t do anything yet. We will change that in two ways.
We will respond to the keyboard inputs read by our InputReceiver. This will take place in the handleInput function. At this point, the player will be able to move. Once we have done this, we will move on to animating the movement.
Coding the player controls
PlayerUpdate.h already has all the variables we need; we just need to utilize them in the PlayerUpdate.cpp file. Add the full code of the handleInput function to PlayerUpdate.cpp. Here is the function in its entirety:
void PlayerUpdate::handleInput()
{
if (event.type == Event::KeyPressed)
{
if (event.key.code == Keyboard::D)
{
m_RightIsHeldDown = true;
}
if (event.key.code == Keyboard::A)
{
m_LeftIsHeldDown = true;
}
if (event.key.code == Keyboard::W)
...