I have been following the Game From Scratch tutorial and it is coded in 1.6.
I think I have everything right except the code for sf::Input I looked at the documentation and cant seem to figure it out.Here is the code, if anyone can give some info i would greatly appreciate it.
const sf::Input& Game::GetInput()
{
return _mainWindow.GetInput();
}
I already know that it should be keyPressed and Keyboard
void PlayerPaddle::Update(float elapsedTime)
{
if(Game::GetInput().IsKeyDown(sf::Key::Left))
{
this->_velocity-= 5.0f;
}
if(Game::GetInput().IsKeyDown(sf::Key::Right))
{
this->_velocity+= 5.0f;
}
if(Game::GetInput().IsKeyDown(sf::Key::Down))
{
this->_velocity= 0.0f;
}
if(_velocity > _maxVelocity)
this->_velocity = _maxVelocity;
if(_velocity < -_maxVelocity)
this->_velocity = -_maxVelocity;
sf::Vector2f pos = this->GetPosition();
if(pos.x < GetSprite().GetSize().x/2
|| pos.x > (Game::SCREEN_WIDTH - GetSprite().GetSize().x/2))
{
_velocity = -_velocity; // Bounce by current velocity in opposite direction
}
GetSprite().Move(_velocity * elapsedTime, 0);
}