Advertisement
Corosus

Untitled

Mar 27th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.93 KB | None | 0 0
  1. void map::renderTileMap(Tile* tileMap, const Uint8 r, const Uint8 g, const Uint8 b, bool showText, int xoffset) {
  2.     SDL_Rect clip2;
  3.     SDL_Rect clip3;
  4.     /*clip2.x = this->ViewportInfo.gui_x;
  5.     clip2.y = this->ViewportInfo.gui_y;
  6.     clip2.w = this->ptrScreen->VIEWPORT_WIDTH;
  7.     clip2.h = this->ptrScreen->VIEWPORT_HEIGHT;*/
  8.    
  9.    
  10.  
  11.  
  12.     for (int i = 0; i < this->WorldInfo.total_tiles; i++) {
  13.         if (tileMap[i].Occupied == true) {
  14.             //if (this->ptrWorld->Map->path_map[i].Occupied == true) {
  15.             int yT = (int)(i / this->WorldInfo.tiles_count_x);     
  16.             int xT = fmod(i*1.0f,this->WorldInfo.tiles_count_x*1.0f);
  17.  
  18.             int xP = xT*this->WorldInfo.tile_size;
  19.             int yP = yT*this->WorldInfo.tile_size;
  20.  
  21.            
  22.             if (this->inViewport(xP,yP,this->WorldInfo.tile_size,this->WorldInfo.tile_size)) {
  23.  
  24.                 clip2.x = xP;
  25.                 clip2.y = yP;
  26.                 clip2.w = 32;
  27.                 clip2.h = 32;
  28.  
  29.                 //clip2 = this->clipToViewport(xP,yP,clip2);
  30.  
  31.                 int xViewOffset = this->ViewportInfo.gui_x + (xP - this->ViewportInfo.x);
  32.                 int yViewOffset = this->ViewportInfo.gui_y + ((yP) - this->ViewportInfo.y);
  33.  
  34.                 clip3.x = xViewOffset+xoffset;
  35.                 clip3.y = yViewOffset;
  36.                 clip3.w = 32;
  37.                 clip3.h = 32;
  38.  
  39.                
  40.  
  41.                
  42.                 SDL_FillRect( ptrScreen->screen, &clip3, SDL_MapRGB( ptrScreen->screen->format, r, g, b ) );
  43.                
  44. #ifdef SHOW_DEBUG_TEXT
  45.                 if (showText){
  46.                     sstr.str("");
  47.                     //sstr.str("speed: ");
  48.                     //sstr<<this->vector<<" - "<<this->targetvector;
  49.                     //sstr<<tileMap[i].OccupyData.size();
  50.  
  51.                     //extra if statement for thread safety
  52.                     if (tileMap[i].Occupied == true) {
  53.                         sstr<<tileMap[i].OccupyData[0];
  54.                     }
  55.                     //sstr<<this->animation_list.curAnimFrame<<" - "<<this->angle.frame;
  56.                     str1 = sstr.str();
  57.                     ptrWorld->ptrScreen->printText(xViewOffset+xoffset,yViewOffset,str1.c_str());
  58.                 }
  59. #endif
  60.  
  61.                 //this->ptrScreen->apply_surface(xViewOffset,yViewOffset,
  62.                 //this->ResID->surface,this->ptrScreen->screen,&clip);
  63.  
  64.             }
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement