summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-11 15:33:28 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-11 15:33:28 -0500
commit6cfc54f019ea793c75c012af9c8249eac936cfac (patch)
treef19eed64e9b284136f3b802d4dee71ee24978646 /src/main.cpp
parent456122f5f0086ed0dbe1b784266b96e9624aa8e1 (diff)
downloadether-6cfc54f019ea793c75c012af9c8249eac936cfac.tar.gz
ether-6cfc54f019ea793c75c012af9c8249eac936cfac.tar.bz2
ether-6cfc54f019ea793c75c012af9c8249eac936cfac.zip
Added music and lamp popping sound
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 4b13051..25da94f 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -13,6 +13,10 @@ void incrementIfSet(Game& game, int& count, int x, int y, Tile val = Tile::Wall)
13 } 13 }
14} 14}
15 15
16int getZoomLevel(const Game& game) {
17 return (game.curZoom - INIT_ZOOM) / 2;
18}
19
16void tick( 20void tick(
17 Game& game, 21 Game& game,
18 int x1, 22 int x1,
@@ -96,11 +100,14 @@ bool movePlayer(Game& game, int x, int y)
96 100
97 game.player_x = x; 101 game.player_x = x;
98 game.player_y = y; 102 game.player_y = y;
103 game.muxer.setPlayerLoc(x, y);
99 104
100 game.dirtyLighting = true; 105 game.dirtyLighting = true;
101 106
102 return true; 107 return true;
103 } else { 108 } else {
109 //game.muxer.playSoundAtPosition("bump", game.player_x, game.player_y);
110
104 return false; 111 return false;
105 } 112 }
106} 113}
@@ -241,6 +248,8 @@ void kickUpDust(Game& game, int x, int y, size_t chain)
241 248
242void popLamp(Game& game, int x, int y, size_t chain) 249void popLamp(Game& game, int x, int y, size_t chain)
243{ 250{
251 game.muxer.playSoundAtPosition("pop", x, y);
252
244 if (game.map.at(x,y).tile == Tile::Lamp) 253 if (game.map.at(x,y).tile == Tile::Lamp)
245 { 254 {
246 game.numLamps--; 255 game.numLamps--;
@@ -400,6 +409,15 @@ void setZoom(Game& game, size_t zoom)
400 { 409 {
401 game.curBoundY = game.map.getBottom() - zoom * ZOOM_Y_FACTOR; 410 game.curBoundY = game.map.getBottom() - zoom * ZOOM_Y_FACTOR;
402 } 411 }
412
413 int zoomLevel = getZoomLevel(game);
414 if (zoomLevel == 0) {
415 game.muxer.setMusicLevel(0);
416 } else if (zoomLevel < 3) {
417 game.muxer.setMusicLevel(1);
418 } else {
419 game.muxer.setMusicLevel(2);
420 }
403} 421}
404 422
405int main(int, char**) 423int main(int, char**)
@@ -731,6 +749,7 @@ int main(int, char**)
731 zoomAcc -= zoomDt; 749 zoomAcc -= zoomDt;
732 } 750 }
733 751
752 game.muxer.update();
734 renderer.render(game, true); 753 renderer.render(game, true);
735 } 754 }
736 } catch (const sdl_error& ex) 755 } catch (const sdl_error& ex)