title: Is there a way to draw a background sprite over and over? Or to add a background sprite on top of each other?
body: <p>So I am trying to make a platform that is based on JumpKing and I want to use my sprite image and make it so that it repeats it over and over vertically. Is there a way to make it loop or can you add a sprite background on top of each other.</p>
  <pre><code>Background::Background()
  {
      background.setTexture(Images::getImage(BACKGROUND));
  }
  
  void Background::draw(sf::RenderTarget &amp;window, sf::RenderStates states) const
  {
      if(!getStates(HIDDEN)){
          window.draw(background);
      }
  }
  
  void Background::setScale(float x, float y)
  {
      background.setScale(x, y);
  }
  </code></pre>
  <p>This is the code that where I am drawing the background, it is taking the getImage that is from the images.cpp. The getStates is saying that if the getState is hidden then it won't draw the background.</p>
  <pre><code>std::map&lt;ImageName, sf::Texture&gt; Images::images;
  std::string Images::getImagePath(ImageName name)
  {
      switch(name){
          case JUMP_KING: return &quot;Images/Megaman.png&quot;;
          case BACKGROUND: return &quot;Images/sky background.png&quot;;
          case PLATFORM: return &quot;Images/platforms.png&quot;;
      }
      return std::string();
  }
  
  void Images::loadImage(ImageName name)
  {
      images[name].loadFromFile(getImagePath(name));
  }
  
  sf::Texture &amp;Images::getImage(ImageName name)
  {
      loadImage(name);
      return images[name];
  }
  </code></pre>
  <p>This Images.cpp is there it loads the images in my folder for my game</p>
  <pre><code>States::States()
  {
      for(int i=0; i&lt;LAST_STATE; i++){
          states[StatesEnum(i)] = false;
      }
  }
  
  bool States::getStates(StatesEnum state) const
  {
      return states.at(state);
  }
  
  void States::disableState(StatesEnum state)
  {
      states[state] = false;
  }
  
  void States::enableState(StatesEnum state)
  {
      states[state] = true;
  }
  
  void States::toggleState(StatesEnum state)
  {
      states[state] = !states[state];
  }
  </code></pre>
  <pre><code>enum StatesEnum{
      WARP,
      WARP_HORIZONTAL,
      WARP_VERTICAL,
      FORWARD,
      BACKWARD,
      HIDDEN,
      JUMP,
      GOING_UP,
      LAST_STATE
  }
  </code></pre>
  <p>This is my state enum which goes to the states.cpp so that the these states can be used.
  This is how my background.cpp is using that</p>