File tree Expand file tree Collapse file tree 6 files changed +13
-4
lines changed Expand file tree Collapse file tree 6 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -379,12 +379,14 @@ void Game::UnloadData()
379
379
UnloadFont (mFont );
380
380
}
381
381
382
- void Game::PlaySoundFromMap (const std::string& name)
382
+ void Game::PlaySoundFromMap (const std::string& name, float volume )
383
383
{
384
384
auto iter = mSoundMap .find (name);
385
385
if (iter != mSoundMap .end ())
386
386
{
387
- PlaySound (mSoundMap [name]);
387
+ Sound sound = mSoundMap [name];
388
+ SetSoundVolume (sound, volume);
389
+ PlaySound (sound);
388
390
}
389
391
else
390
392
{
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class Game
45
45
int GetScreenHeight () const { return mScreenHeight ; }
46
46
std::unordered_map<std::string, Sound>& GetSoundMap () { return mSoundMap ; }
47
47
48
- void PlaySoundFromMap (const std::string& name);
48
+ void PlaySoundFromMap (const std::string& name, float volume = 1 . 0f );
49
49
50
50
// void AddFont(class Font* font);
51
51
// void RemoveFont(class Font* font);
Original file line number Diff line number Diff line change @@ -97,25 +97,31 @@ void Grid::ToggleSeal(Cell* cell)
97
97
{
98
98
cell->SetCellType (SEALED);
99
99
mTotalSeals --;
100
+ GetGame ()->PlaySoundFromMap (" toggle-seal-click.wav" , 0 .5f );
101
+
100
102
return ;
101
103
}
102
104
else if (cell->GetCellType () == MINE && mTotalSeals > 0 )
103
105
{
104
106
cell->SetCellType (MINE_SEALED);
105
107
mTotalSeals --;
108
+ GetGame ()->PlaySoundFromMap (" toggle-seal-click.wav" , 0 .5f );
106
109
CheckForWin ();
110
+
107
111
return ;
108
112
}
109
113
110
114
if (cell->GetCellType () == SEALED)
111
115
{
112
116
cell->SetCellType (UNEXPOSE);
113
117
mTotalSeals ++;
118
+ GetGame ()->PlaySoundFromMap (" toggle-seal-click.wav" , 0 .5f );
114
119
}
115
120
else if (cell->GetCellType () == MINE_SEALED)
116
121
{
117
122
cell->SetCellType (MINE);
118
123
mTotalSeals ++;
124
+ GetGame ()->PlaySoundFromMap (" toggle-seal-click.wav" , 0 .5f );
119
125
}
120
126
}
121
127
@@ -212,10 +218,11 @@ void Grid::Expose(Cell *cell)
212
218
{
213
219
mine->SetCellType (MINE_EXPOSE);
214
220
}
221
+ GetGame ()->PlaySoundFromMap (" mine-click.wav" );
215
222
}
216
223
else if (cell->GetCellType () == UNEXPOSE)
217
224
{
218
- GetGame ()->PlaySoundFromMap (" cell-click.wav" );
225
+ GetGame ()->PlaySoundFromMap (" cell-click.wav" , 2 . f );
219
226
// Check if its a normal cell
220
227
std::vector<Cell*> adjacentCells;
221
228
int numOfMines = GetAdjacentCells (cell, adjacentCells);
You can’t perform that action at this time.
0 commit comments