diff --git a/GameWindow.h b/GameWindow.h index 3d4c6cc..23f869d 100644 --- a/GameWindow.h +++ b/GameWindow.h @@ -119,7 +119,23 @@ class GameWindow{ gameActive = true; leaderBoard.setUpdated(false); } - leaderBoard.buttonPressed(sf::Mouse().getPosition(window), numOfCols, numOfRows); + + if(leaderBoard.buttonPressed(sf::Mouse().getPosition(window))) + { + for (int l = 0; l < numOfCols; l++) { + for (int m = 0; m < numOfRows; m++) { + board.openAll(l, m); + window.draw(board.getBoard()[l][m]->sprite); + } + } + window.display(); + leaderBoard.drawWindow(numOfCols, numOfRows); + for(int i = 0; i < numOfCols; i++) { + for (int j = 0; j < numOfRows; j++) { + board.openTile(sf::Mouse().getPosition(window), i, j); + } + } + } if(debugButton.buttonPressed(sf::Mouse().getPosition(window)) && gameActive && !paused){ debugButton.setDebugActive(!debugButton.getDebugActive()); for(int bombs = 0; bombs < numOfCols; bombs++){ diff --git a/Leaderboard.h b/Leaderboard.h index f4e4fe8..2cbb92e 100644 --- a/Leaderboard.h +++ b/Leaderboard.h @@ -51,23 +51,27 @@ class LeaderBoard : public Button { } } - void buttonPressed(Vector2i mousePos, int numOfCols, int numOfRows) { + bool buttonPressed(Vector2i mousePos) { if (sprite.getGlobalBounds().contains(static_cast(mousePos))) { - sf::RenderWindow window(sf::VideoMode(numOfCols * 16, numOfRows * 16 + 50), "Leaderboard"); - while (window.isOpen()) { - sf::Event event{}; - while (window.pollEvent(event)) { - if (event.type == sf::Event::Closed) { - window.close(); - } + return true; + } + } + void drawWindow(int numOfCols, int numOfRows){ + sf::RenderWindow window(sf::VideoMode(numOfCols * 16, numOfRows * 16 + 50), "Leaderboard"); - sf::Text leaderBoardLine = drawWord("LeaderBoard", numOfCols*8, numOfRows*8-120, 20); - sf::Text leaderBoardContents = drawWord(leaderBoard, numOfCols*8, numOfRows*8 + 20, 18); - window.clear(sf::Color::Blue); - window.draw(leaderBoardLine); - window.draw(leaderBoardContents); - window.display(); + while (window.isOpen()) { + sf::Event event{}; + while (window.pollEvent(event)) { + if (event.type == sf::Event::Closed) { + window.close(); } + + sf::Text leaderBoardLine = drawWord("LeaderBoard", numOfCols*8, numOfRows*8-120, 20); + sf::Text leaderBoardContents = drawWord(leaderBoard, numOfCols*8, numOfRows*8 + 20, 18); + window.clear(sf::Color::Blue); + window.draw(leaderBoardLine); + window.draw(leaderBoardContents); + window.display(); } } } diff --git a/numberTile.h b/numberTile.h index c64a833..0d9325d 100644 --- a/numberTile.h +++ b/numberTile.h @@ -1,4 +1,4 @@ -#include "GameObject.h" +#include "Mine.h" #include using namespace std; class numberTile : public GameObject{