I been following a tutorial word for word but i get an error which I couldn’t get the answer solved from the guy who made the tutorial!
I got to this section of the tutorial which is where it went wrong:
http://www.gamefromscratch.com/page/Game-From-Scratch-CPP-Edition-Part-6.aspx
The error i get is:
playerpaddle.cpp(32): error C2039: 'IsKeyDown' : is not a member of 'tagINPUT'
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winuser.h(5332) : see declaration of 'tagINPUT'
playerpaddle.cpp(36): error C2039: 'IsKeyDown' : is not a member of 'tagINPUT'
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winuser.h(5332) : see declaration of 'tagINPUT'
playerpaddle.cpp(40): error C2039: 'IsKeyDown' : is not a member of 'tagINPUT'
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\winuser.h(5332) : see declaration of 'tagINPUT'
1>c:\users\dave\c++\pang\playerpaddle.cpp(54): error C2064: term does not evaluate to a function taking 1 arguments
With this script section:
void PlayerPaddle::Update(float elapsedTime)
{
if(Game::GetInput().IsKeyDown(sf::Key::Left))
{
_velocity-=3.0f;
}
if(Game::GetInput().IsKeyDown(sf::Key::Right))
{
_velocity+=3.0f;
}
if(Game::GetInput().IsKeyDown(sf::Key::Down))
{
_velocity = 0.0f;
}
if(_velocity > _maxVelocity)
_velocity = _maxVelocity;
if(_velocity < -_maxVelocity)
_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;
}
GetSprite().Move(_velocity * elapsedTime, 0);
}
I attached my project for some one to take a look at:
http://tinyurl.com/7evajju
The GetInput() static in Game is returning a windows struct. Pretty sure that’s not what you wanted as that struct has only data and no methods. This function isn’t actually implemented, so if you ‘just make the errors go away’, you’ll still have a linker error for an undefined symbol.
You see it as ‘_tagINPUT’ as an effect of how windows typedef declares structures.
You probably intended to return a ‘Input’ class as defined in include\SFML\Window\Input.hpp
I believe you would typically call GetInput() on the SFML Window class.
So maybe all you wanted was game.h to instead have:
I think you would do well to focus on C++ as a language before diving so deep into game programming. If game programming is all you are interested in, you may want to look into higher level technologies that will let you make games. Going down the C/C++ road without investing in understanding the language is likely to cause you enough pain that you will end up hating what you are doing, which would be unfortunate.