I'm having trouble creating a scrolling background. I'm literally trying to translate the C# I did two years ago, in to C++ and as a 'newb' (as it were), I'm having trouble.
Below are the variables and objects I am using.
//ScrollingBackground Inits from the Contructor/Main Method
_screenHeight = Graphics::GetViewportHeight();
_screenWidth = Graphics::GetViewportWidth();
//ScrollingBackground Content from the Load Content Method
_backgroundPosition = new Vector2(_screenWidth / 2, _screenHeight / 2);
_origin = new Vector2(_backgroundTexture->GetHeight() / 2, 0);
_textureSize = new Vector2(0, _backgroundTexture->GetHeight());
_backgroundTexture->Load("background.dds", false);
This is the Method that I'm trying to make where the scrolling occurs.
void Player::Scrolling(float deltaX)
{
//This is where the scrolling happens
_backgroundPosition->X += deltaX;
_backgroundPosition->X = _backgroundPosition->X % _textureSize->Y;
}
Still relatively new to this so please forgive me if I'm vague or sound like I don't have a clue what I'm talking about.
Many thanks,
Ryan.