Skip to content

Commit

Permalink
Debug button appears at bottom of game window
Browse files Browse the repository at this point in the history
  • Loading branch information
EAOZONE committed Apr 15, 2024
1 parent 84d622a commit a3f8a31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void calculateNearbyBombs(){
}
void setDebug(int i, int j){
if(board[i][j]->getIsMine()) {
board[i][j]->setTexture("../Project 3 - Minesweeper Spring 2024/files/images/debug.png");
board[i][j]->setTexture("../Project 3 - Minesweeper Spring 2024/files/images/mine.png");
board[i][j]->setSprite();
}
}
Expand Down
1 change: 1 addition & 0 deletions DebugButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class DebugButton : public Button{
if(sprite.getGlobalBounds().contains(static_cast<sf::Vector2f>(mousePos))){
return true;
}
return false;
}
};
8 changes: 5 additions & 3 deletions GameWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class GameWindow{
board.setBombs();
board.calculateNearbyBombs();

DebugButton debugButton = DebugButton((numOfCols * 32)-304, 32*(numOfRows + 0.5), "../Project 3 - Minesweeper Spring 2024/files/images/debug.png");
DebugButton debugButton = DebugButton((numOfRows * 32)-304, 32*(numOfCols + 0.5), "../Project 3 - Minesweeper Spring 2024/files/images/debug.png");
cout<<debugButton.position.x<<endl;
while (window.isOpen()) {
sf::Event event{};
while (window.pollEvent(event)) {
Expand All @@ -34,21 +35,22 @@ class GameWindow{
}
}
window.clear(sf::Color::White);
window.draw(debugButton.sprite);
for(int i = 0; i < numOfRows; i++){
for(int j = 0; j<numOfCols; j++) {
window.draw(board.getBoard()[i][j]->sprite);
if (sf::Mouse().isButtonPressed(Mouse::Right)) {
board.mouseRightClicked(sf::Mouse().getPosition(window), i, j);
}
else if (sf::Mouse().isButtonPressed(Mouse::Left)){
// if(debugButton.buttonPressed(sf::Mouse().getPosition(window))){
if(debugButton.buttonPressed(sf::Mouse().getPosition(window))){
for(int bombs = 0; bombs < numOfRows; bombs++){
for(int b = 0; b < numOfCols; b++){
board.setDebug(bombs, b);
if(board.getBoard()[bombs][b]->getIsMine()){
}
}
// }
}
}
board.openTile(sf::Mouse().getPosition(window), i, j);
}
Expand Down

0 comments on commit a3f8a31

Please sign in to comment.