Skip to content

Commit

Permalink
CLets user hide bombs if debug button is clicked again
Browse files Browse the repository at this point in the history
  • Loading branch information
EAOZONE committed Apr 15, 2024
1 parent a3f8a31 commit d68c3cd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 7 additions & 1 deletion Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,15 @@ void calculateNearbyBombs(){
return bombExploded;
}
void setDebug(int i, int j){
if(board[i][j]->getIsMine()) {
if(board[i][j]->getState() == hidden) {
board[i][j]->setTexture("../Project 3 - Minesweeper Spring 2024/files/images/mine.png");
board[i][j]->setSprite();
board[i][j]->setState(revealed);
}
else if(board[i][j]->getState() == revealed){
board[i][j]->setTexture("../Project 3 - Minesweeper Spring 2024/files/images/tile_hidden.png");
board[i][j]->setSprite();
board[i][j]->setState(hidden);
}
}
};
8 changes: 0 additions & 8 deletions GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,10 @@ class GameObject {
Vector2f position;
Texture texture;
Sprite sprite;
void setTexture(Texture texture){
this->texture = texture;
setSprite();
}
void setTexture(std::string textureFile){
texture.loadFromFile(textureFile);
setSprite();
}
void setPosition(Vector2f position){
this->position = position;

}
void setPosition(float x, float y){
this->position.x = x;
this->position.y = y;
Expand Down
2 changes: 1 addition & 1 deletion GameWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class GameWindow{
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.setDebug(bombs, b);
}
}
}
Expand Down

0 comments on commit d68c3cd

Please sign in to comment.