SFML community forums
Help => General => Topic started by: GameMasterShift on December 16, 2014, 06:33:32 pm
-
Alright so i am using the SFML view to have the screen centered on top of the players sprite the Yellow is the y coordinate and the Blue is the X coordinate , now the thing is everything i press the corresponding key such has the up arrow the screen will always move to far in that direction and i have adjusted the numbers to where it moves slower or fast but it dose not help , so is there a way to keep the SFML view always centered with the player sprite , and by view i am talking about the 2d view option http://www.sfml-dev.org/tutorials/2.0/graphics-view.php (http://www.sfml-dev.org/tutorials/2.0/graphics-view.php)
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
{
Yellow = -200;
Blue = 0;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
Yellow = 200;
Blue = 0;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
Yellow = 0;
Blue = -3.33333;
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
{
Yellow = 0;
Blue = 3.33333;
}
-
This post makes only sense to you.
What has the code to do with what you said in your text? What is Yellow and Blue? Where is the view? What exactly doesn't work? Etc.
Read this: http://en.sfml-dev.org/forums/index.php?topic=5559.0
-
Blue is being altered a lot less than yellow so expect horizontal translation to be much less than vertical translation.
If it's still moving too quickly, the number is still too high. However, you should consider multiplying it with delta time.