From 6cfc54f019ea793c75c012af9c8249eac936cfac Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 11 Mar 2022 15:33:28 -0500 Subject: Added music and lamp popping sound --- src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main.cpp') 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) } } +int getZoomLevel(const Game& game) { + return (game.curZoom - INIT_ZOOM) / 2; +} + void tick( Game& game, int x1, @@ -96,11 +100,14 @@ bool movePlayer(Game& game, int x, int y) game.player_x = x; game.player_y = y; + game.muxer.setPlayerLoc(x, y); game.dirtyLighting = true; return true; } else { + //game.muxer.playSoundAtPosition("bump", game.player_x, game.player_y); + return false; } } @@ -241,6 +248,8 @@ void kickUpDust(Game& game, int x, int y, size_t chain) void popLamp(Game& game, int x, int y, size_t chain) { + game.muxer.playSoundAtPosition("pop", x, y); + if (game.map.at(x,y).tile == Tile::Lamp) { game.numLamps--; @@ -400,6 +409,15 @@ void setZoom(Game& game, size_t zoom) { game.curBoundY = game.map.getBottom() - zoom * ZOOM_Y_FACTOR; } + + int zoomLevel = getZoomLevel(game); + if (zoomLevel == 0) { + game.muxer.setMusicLevel(0); + } else if (zoomLevel < 3) { + game.muxer.setMusicLevel(1); + } else { + game.muxer.setMusicLevel(2); + } } int main(int, char**) @@ -731,6 +749,7 @@ int main(int, char**) zoomAcc -= zoomDt; } + game.muxer.update(); renderer.render(game, true); } } catch (const sdl_error& ex) -- cgit 1.4.1