Problem with my script

Started by
4 comments, last by CelticSir 12 years, 1 month ago
Hey

I have been following "Game From Scratch" tutorials on building a game but my script won't build.

I got to step 6 here: http://www.gamefroms...ion-Part-6.aspx

I get the following errors:



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
[/quote]

Its related to this :



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);
}


What does the error mean so i can work out how i fix it =/ ?

Thanks
Advertisement
The author seems to have forgotten to #include "SFML/Input.hpp", leaving your compiler confused as to what this "sf::Input" nonsense is, making a guess, and guessing incorrectly.

If I'm guessing correctly, at any rate.

The author seems to have forgotten to #include "SFML/Input.hpp", leaving your compiler confused as to what this "sf::Input" nonsense is, making a guess, and guessing incorrectly.

If I'm guessing correctly, at any rate.



There is no Input.hpp in 1.6, at least not one you invoke directly.


That said, I think that is exactly what the problem is. I did make one massive stupid mistake in the tutorial, in that I put the includes in the stdafx.h files, then.... well, forgot to document that step. I've since fixed that ommission, but if you started after I made that fix things would be extremely stupid.

@theFollower, check your stdafx.h and make sure it includes "#include "SFML/Window.hpp".
Hi,

Yes line 15 has:

#include <SFML/Window.hpp>

Should i upload my project to check it or is there something else i can check ?

Hi,

Yes line 15 has:

#include <SFML/Window.hpp>

Should i upload my project to check it or is there something else i can check ?



So, in seeing the code ( posted on StackOverflow ) I see the problem ( your typo ), but you already have your answer on that site, so no need to go into further detail here, unless you are still unclear why you have a problem here.
Ah okay didn't know any one had replied! Knew it was going to be a needle in the haystack ! What a headache that was :P Thanks!

This topic is closed to new replies.

Advertisement