Skip to content

Commit

Permalink
resets counter at beginning of game
Browse files Browse the repository at this point in the history
  • Loading branch information
EAOZONE committed Apr 21, 2024
1 parent 0cbd958 commit 99ccfb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void calculateNearbyBombs(){

}
void reset(){
counter->reset();
for(int i = 0; i < numOfRows; i++){
for(int j = 0; j < numOfCols; j++){
board[i][j] = new Tile(i*32, j*32, "../Project 3 - Minesweeper Spring 2024/files/images/tile_hidden.png");
Expand Down
14 changes: 13 additions & 1 deletion Counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ class Counter : public GameObject{
private:
Sprite sprites[3];
int digits[3];
int numOfBombs;
public:
Counter(int numOfBombs, int numOfCols) {

this->numOfBombs = numOfBombs;
int update = numOfBombs;
this->digits[2] = update % 10;
update = update / 10;
Expand Down Expand Up @@ -71,6 +72,17 @@ class Counter : public GameObject{
this->sprites[1].setTextureRect(IntRect(0 + 21 * this->digits[1], 0, 21, 32));
this->sprites[2].setTextureRect(IntRect(0 + 21 * this->digits[2], 0, 21, 32));
}
void reset(){
int update = numOfBombs;
this->digits[2] = update % 10;
update = update / 10;
this->digits[1] = update % 10;
update = update / 10;
this->digits[0] = update % 10;
this->sprites[0].setTextureRect(IntRect(0 + 21 * this->digits[0], 0, 21, 32));
this->sprites[1].setTextureRect(IntRect(0 + 21 * this->digits[1], 0, 21, 32));
this->sprites[2].setTextureRect(IntRect(0 + 21 * this->digits[2], 0, 21, 32));
}
Sprite getDigits(int i){
return this->sprites[i];
}
Expand Down

0 comments on commit 99ccfb1

Please sign in to comment.