• Advertisement
Sign in to follow this  

Player movement.

This topic is 2239 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have drawn a player with OpenGL and want to put keyboard movement on it. I will be using the GetKeyState() function.
So far I have a move method in my player class.

void CPlayer::move(float x,float y,float z)
{
m_xPos += x;
m_yPos += y;
m_zPos += z;
}

the m_xPos varianles are member variables intialised in a constructor and passed into a translate function in my drawPlayer function, move will update the position of the player.

To manage the key presses I have a PlayerKeys function in main which calls move.

void PlayerKeys(){

if (GetKeyState(VK_UP))
{
g_Player1.move(0.0f, 100.0f, 0.0f);
}

else if(GetKeyState(VK_UP)>0)
{

}
}

The problem is when I call this method in my main loop in main I get an error message identifier not found. I would also be grateful if any one has suggestions for how best to implement my PlayerKeys function as I don't think it is quite right at the moment.

Share this post


Link to post
Share on other sites
Advertisement
Which identifier is not found, is it GetKeyState or PlayerKeys?

Is the PlayerKeys function declared before, after or inside the main function?

Share this post


Link to post
Share on other sites
Hi Pulpfist,

Fixed the identifier problem, like an idiot didn't declare in main.h, I am still trying to write the PlayerKeys function if you have any suggestions would be grateful. Its the same as above just added more keys.

Thanks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement