void MinimapGUI::display() {
int cellWidth = 10;
int cellHeight = 10;
for(int i = 0; i < roomGrid.size(); i++) {
for(int j = 0; j < roomGrid[i].size(); j++) {
if(roomGrid[i][j] != nullptr) {
auto room = roomGrid[i][j];
auto playerRoom = dungeon->getCurrentRoom();
if(room->doorBottom && playerRoom == room && !roomGrid[i + 1][j]->explored) {
SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
SDL_Rect rect = {j * cellWidth, (i + 1) * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
roomGrid[i + 1][j]->spotted = true;
}
if(room->doorTop && playerRoom == room && !roomGrid[i - 1][j]->explored) {
SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
SDL_Rect rect = {j * cellWidth, (i - 1) * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
roomGrid[i - 1][j]->spotted = true;
}
if(room->doorLeft && playerRoom == room && !roomGrid[i][j - 1]->explored) {
SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
SDL_Rect rect = {(j - 1) * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
roomGrid[i][j - 1]->spotted = true;
}
if(room->doorRight && playerRoom == room && !roomGrid[i][j + 1]->explored) {
SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
SDL_Rect rect = {(j + 1) * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
roomGrid[i][j + 1]->spotted = true;
}
if(room->spotted) {
SDL_SetRenderDrawColor(getRenderer(), 255, 255, 0, 255);
SDL_Rect rect = {j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
}
// EXPLORED ROOMS ARE GREEN
if(room->explored) {
SDL_SetRenderDrawColor(getRenderer(), 0, 255, 0, 255);
SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
}
// STARTING ROOM IS BLUE
if(roomGrid[i][j]->gridY == 0 && roomGrid[i][j]->gridX == 0) {
SDL_SetRenderDrawColor(getRenderer(), 0, 0, 255, 255);
SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
}
// CURRENT ROOM IS RED
if(room == playerRoom) {
SDL_SetRenderDrawColor(getRenderer(), 255, 0, 0, 255);
SDL_Rect rect = { j * cellWidth, i * cellHeight, cellWidth - 5, cellHeight - 5};
SDL_RenderFillRect(getRenderer(), &rect);
}
}
}
}
}
Comments