title: Problems blitting surface in SDL from vector of SDL_Rect
body: <pre><code>#include "main.h"
  
  SDL_Surface* screen; //The screen Surface
  SDL_Surface* Snake_Body; //The snake surface (shape to draw)
  
  SDL_Rect rectangle1; //Red border
  SDL_Rect rectangle2; //Black Board
  
  SDL_Event event;    //Keyboard handling
  direction facing;
  
  std::vector&lt;SDL_Rect&gt; snake (3); //Snake body locations
  
  
  
  SDL_Surface *LoadSnake()
  {
      SDL_Surface* temporary;
  
      Uint32 rmask,gmask,bmask,amask;
  
      #if SDL_BYTEORDER == SDL_BIG_ENDIAN
          rmask = 0xff000000;
          gmask = 0x00ff0000;
          bmask = 0x0000ff00;
          amask = 0x000000ff;
      #else
          rmask = 0x000000ff;
          gmask = 0x0000ff00;
          bmask = 0x00ff0000;
          amask = 0xff000000;
      #endif
  
      temporary = SDL_CreateRGBSurface(SDL_SWSURFACE,5,5,32,rmask,gmask,bmask,amask); //Make an empty surface
  
      SDL_FillRect(temporary,NULL,SDL_MapRGB(screen-&gt;format,0,255,0)); //Fill it with color
  
      return temporary; //return it
  }
  
  
  bool init()
  {
      if(SDL_Init(SDL_INIT_EVERYTHING) == -1 )
          return false;
  
      screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,SDL_SWSURFACE);
  
      if(!screen)
          return false;
  
      SDL_WM_SetCaption("Snake v0.1",NULL);
  
      Snake_Body = LoadSnake();
  
      rectangle1.x = 0;  //Red border
      rectangle1.y = 0;
      rectangle1.w = 500;
      rectangle1.h = 500;
  
      rectangle2.x = 25; //Black background
      rectangle2.y = 25;
      rectangle2.w = 450;
      rectangle2.h = 450;
  
      return true;
  }
  
  SDL_Surface *loadImage(const char* filename)
  {
      SDL_Surface *loadedImage = NULL;
      SDL_Surface *optimizedImage = NULL;
  
      loadedImage = SDL_LoadBMP(filename);
  
      if (loadedImage)
      {
          optimizedImage = SDL_DisplayFormat(loadedImage);
          SDL_FreeSurface(loadedImage);
      }
  
      return optimizedImage;
  }
  
  void pollInput()
  {
      while(SDL_PollEvent(&amp;event))
      {
          if(event.type == SDL_QUIT)
          {
              end = true;
          }
  
          if(event.type == SDL_KEYUP)
          {
              switch(event.key.keysym.sym)
              {
              case SDLK_ESCAPE:
                  end = true; break;
              case SDLK_UP:
                  facing = up; break;
              case SDLK_DOWN:
                  facing = down; break;
              case SDLK_RIGHT:
                  facing = right; break;
              case SDLK_LEFT:
                  facing = left; break;
              }
          }
      }
  }
  
  void Update()
  {
      for(unsigned int i = 1; i &lt; snake.size(); i++)
      {
          snake[i] = snake[i-1];
      }
  
      switch(facing)
      {
      case up:
          snake[0].y -= 5; break;
      case down:
          snake[0].y += 5; break;
      case left:
          snake[0].x -= 5; break;
      case right:
          snake[0].x += 5; break;
      }
  
  }
  
  void SetUp()
  {
      snake[0].x = 250;
      snake[0].y = 250;
  
  
      snake[1].x = 250 + 15;
      snake[1].y = 250;
  
      snake[2].x = 250 + 15 + 15;
      snake[2].y = 250;
  }
  
  void Draw()
  {
      unsigned short i;
      int x;
  
      SDL_FillRect(screen,&amp;rectangle1,SDL_MapRGB(screen-&gt;format,255,0,0)); //Red Border
  
      SDL_FillRect(screen,&amp;rectangle2,SDL_MapRGB(screen-&gt;format,0,0,0)); //Black Board
  
      for(i = 0; i &lt; snake.size(); i++)
      {
          assert(SDL_BlitSurface(Snake_Body,NULL,screen,&amp;snake[i]) == 0);
      }
  
      SDL_Flip(screen);
  }
  
  void Finish()
  {
      SDL_FreeSurface(Snake_Body);
  
      SDL_Quit();
  }
  </code></pre>
  
  <p>I have this code, it's a game of snake written in SDL I am working on, however, I seem to have a problem.</p>
  
  <p>SDL draws the background just fine, but for some reason it won't draw the snake.
  I set up an assert over there to check if the SDL_BlitSurface function succeeded, and it returns a normal value (0), even though nothing shows up on screen.</p>
  
  <p>I set up the texture of the snake node to be a single green rectangle, Snake_Body, and I coded the locations that it needs to be drawn in a std::vector container, so I can call the SDL_BlitSurface() function on each of the elements in the vector, I have tracked the values and they are changing correctly, but for some reason the image stil isn't drawn. I have also attempted to replace my SDL_BlitSurface() function with a SDL_FillRect() in the same position, but it doesn't change anything.</p>
  
  <p>EDIT: I have added my main loop below this edit:</p>
  
  <pre><code>#include "main.h"
  
  bool end = false;
  Uint32 time;
  
  int main(int argc,char* argv[])
  {
      if(!init())
          return 1;
  
      SetUp();
  
      time = SDL_GetTicks();
  
      while(!end)
      {
          if(time+1000&lt;SDL_GetTicks())
          {
              Update();
              time = SDL_GetTicks();
          }
  
          pollInput();
          Draw();
      }
  
      Finish();
  
      return 0;
  }
  </code></pre>