Alright
. This is what I done (I simplified). With or without the view I have the same problem. When I run my game the player has a certain speed. But when I scale up the window the player is slower. And when I scale down the window the player is quicker. Why ?
#include <SFML/Graphics.hpp>
int main() {
// Window and view
sf::RenderWindow window(sf::VideoMode(1024, 768), "SFML Test");
sf::View view(sf::FloatRect(0, 0, 720, 480));
window.setView(view);
// Events
sf::Event event;
// Texture and sprite
sf::Texture texture;
texture.loadFromFile("../res/player.png");
sf::Sprite player(texture);
// Main loop
while(window.isOpen()) {
// Check events
while(window.pollEvent(event))
if(event.type == sf::Event::Closed)
window.close();
// Clear window
window.clear(sf::Color::Black);
// Movement
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
player.move(-1, 0);
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
player.move(1, 0);
// Draw the plaxer
window.draw(player);
// End the current frame
window.display();
}
return EXIT_SUCCESS;
}
PS : I added the view because I have a tiled map in my game.