Moortiii

Untitled

Dec 1st, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.35 KB | None | 0 0
  1. void MinimapGUI::display() {
  2.     int cellWidth = 10;
  3.     int cellHeight = 10;
  4.    
  5.     for(int i = 0; i < roomGrid.size(); i++) {
  6.         for(int j = 0; j < roomGrid[i].size(); j++) {
  7.             if(roomGrid[i][j] != nullptr) {
  8.                 auto room = roomGrid[i][j];
  9.                 auto playerRoom = dungeon->getCurrentRoom();
  10.  
  11.                 if(room->doorBottom && playerRoom == room && !roomGrid[i + 1][j]->explored) {
  12.                     SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
  13.                     SDL_Rect rect = {j * cellWidth, (i + 1) * cellHeight, cellWidth - 5, cellHeight - 5};
  14.                     SDL_RenderFillRect(getRenderer(), &rect);
  15.                     roomGrid[i + 1][j]->spotted = true;
  16.                 }
  17.  
  18.                 if(room->doorTop && playerRoom == room && !roomGrid[i - 1][j]->explored) {
  19.                     SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
  20.                     SDL_Rect rect = {j * cellWidth, (i - 1) * cellHeight, cellWidth - 5, cellHeight - 5};
  21.                     SDL_RenderFillRect(getRenderer(), &rect);
  22.                     roomGrid[i - 1][j]->spotted = true;
  23.                 }
  24.  
  25.                 if(room->doorLeft && playerRoom == room && !roomGrid[i][j - 1]->explored) {
  26.                     SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
  27.                     SDL_Rect rect = {(j - 1) * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  28.                     SDL_RenderFillRect(getRenderer(), &rect);
  29.                     roomGrid[i][j - 1]->spotted = true;
  30.                 }
  31.  
  32.                 if(room->doorRight && playerRoom == room && !roomGrid[i][j + 1]->explored) {
  33.                     SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
  34.                     SDL_Rect rect = {(j + 1) * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  35.                     SDL_RenderFillRect(getRenderer(), &rect);
  36.                     roomGrid[i][j + 1]->spotted = true;
  37.                 }
  38.  
  39.                 if(room->spotted) {
  40.                     SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
  41.                     SDL_Rect rect = {j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  42.                     SDL_RenderFillRect(getRenderer(), &rect);
  43.                 }
  44.  
  45.                 // EXPLORED ROOMS ARE GREEN
  46.                 if(room->explored) {
  47.                     SDL_SetRenderDrawColor(getRenderer(), 0, 255, 0, 255);
  48.                     SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  49.                     SDL_RenderFillRect(getRenderer(), &rect);
  50.                 }
  51.  
  52.                 // STARTING ROOM IS BLUE
  53.                 if(roomGrid[i][j]->gridY == 0 && roomGrid[i][j]->gridX == 0) {
  54.                     SDL_SetRenderDrawColor(getRenderer(), 0, 0, 255, 255);
  55.                     SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  56.                     SDL_RenderFillRect(getRenderer(), &rect);
  57.                 }
  58.  
  59.                 // CURRENT ROOM IS RED
  60.                 if(room == playerRoom) {
  61.                     SDL_SetRenderDrawColor(getRenderer(), 255, 0, 0, 255);
  62.                     SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
  63.                     SDL_RenderFillRect(getRenderer(), &rect);
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment