Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: rotating background scrolling  (Read 792 times)

0 Members and 1 Guest are viewing this topic.

xzhang63@gmail.com

  • Newbie
  • *
  • Posts: 2
    • View Profile
rotating background scrolling
« on: February 03, 2012, 06:43:40 pm »
my 1st person view ( avata always at center)
allow avata to chenge angle, therefore the background image can rotate and scroll.

 my total image is twice as large as the monitor composed with tiles with 200 size

Code: [Select]
void CApp::OnLoop() {
   float ElapsedTime = GetFrameTime();
bool k=false;
        if (GetInput().IsKeyDown(sf::Key::Left))  { k=true; Background.Rotate(100 * ElapsedTime);}
        if (GetInput().IsKeyDown(sf::Key::Right)) { k=true; Background.Rotate( -100 * ElapsedTime);}
        if (GetInput().IsKeyDown(sf::Key::Up))    { k=true; Background.Move(0, 100 * ElapsedTime);}
        if (GetInput().IsKeyDown(sf::Key::Down))  { k=true; Background.Move(0, -100 * ElapsedTime);}
        float x = Background.GetPosition().x;
        float y = Background.GetPosition().y;
        float r = Background.GetRotation();
        x=W/2+ fmod(x-W/2,200/fabs(sin(r*M_PI/180)));
        y=H/2+ fmod(y-H/2,200/fabs(cos(r*M_PI/180)));
        Background.SetPosition(x,y);
}


however, when there is an angle, the image is jumpy
when no angle, the program works.
Please help!
Appreciated.