Skip to content

Commit

Permalink
Shows entire gamewindow as open when leaderboard is open
Browse files Browse the repository at this point in the history
  • Loading branch information
EAOZONE committed Apr 22, 2024
1 parent 07cb67c commit e256fce
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
18 changes: 17 additions & 1 deletion GameWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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++){
Expand Down
32 changes: 18 additions & 14 deletions Leaderboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<sf::Vector2f>(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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion numberTile.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "GameObject.h"
#include "Mine.h"
#include <string>
using namespace std;
class numberTile : public GameObject{
Expand Down

0 comments on commit e256fce

Please sign in to comment.