This works perfect for me:
#include <SFML/Graphics.hpp>
int main()
{
// Create the main rendering window
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
sf::Shape Rectangle = sf::Shape::Rectangle(150, 150, 300, 300, sf::Color::Blue, 1.0f, sf::Color::White);
// Start game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
// A key has been pressed
if (Event.Type == sf::Event::KeyPressed)
{
// Escape key : exit
if (Event.Key.Code == sf::Key::Escape)
App.Close();
}
}
// Clear the screen
App.Clear(sf::Color(0, 0, 0));
if (App.GetInput().IsKeyDown(sf::Key::Left)) {
Rectangle.Move(150 * App.GetFrameTime() * -1, 0);
} else if (App.GetInput().IsKeyDown(sf::Key::Right)) {
Rectangle.Move(150 * App.GetFrameTime(), 0);
}
App.Draw(Rectangle);
// Display window contents on screen
App.Display();
}
return EXIT_SUCCESS;
}
Don't know what you really mean with 'Smooth', but it is.