title: Moving Sprite (SFML) in c++ using Loops
body: <p>I am new to c++ and as well as SFML. I am trying to make my sprite object move down in position relative to its last position using a loop. I am looking for the animation of it sprite object falling when the program starts.</p>
  
  <p>I thought implementing a the sleep function in my for loop would help solve the issue i was having where the program would just display the object at the last iteration of the loop. However my program just freezes and crashes. </p>
  
  <p>Looking for some direction. Maybe the sleep function isn't the right thing to call here?</p>
  
  <pre><code>#include &lt;SFML/Graphics.hpp&gt;
  #include &lt;Windows.h&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  
  int main()
  {
      // Create the window here. Calling out the dimensions
      sf::RenderWindow window(sf::VideoMode(800, 600), "Example Window");
  
      // run the program as long as the window is open
      while (window.isOpen())
      {
          sf::Event event;
          while (window.pollEvent(event))
          {
              //close window we requested
              if (event.type == sf::Event::Closed)
              {
                  window.close();
              }
  
          }
  
          window.clear(sf::Color::Black);
  
  
          sf::Texture texture;
          if (!texture.loadFromFile("c:\\abstract.png"))
          {
              cout&lt;&lt;"Failed to load image...";
          }
          sf::Sprite sprite;
          sprite.setTexture(texture);
          sprite.setTextureRect(sf::IntRect(20,20,30,30));
  
  
          for (float i = 0; i &lt; 30.; i++)
          {
              sprite.move(sf::Vector2f(5.f, i));
              window.draw(sprite);
              Sleep(50);
          }
  
  
  
          window.display();
      }
  
      return 0;
  }
  </code></pre>