diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-03 16:30:08 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-12-03 16:30:08 -0500 |
commit | dcd2d1e9ed9df2b67a48acc442c9e816b677b208 (patch) | |
tree | bb9da022908f71323bde29ad8787adf097f3b725 /main.cpp | |
parent | 67803d1c1ef1bb96a6cdfdfecba943378e0ec5d1 (diff) |
moving music to world
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -426,7 +426,7 @@ int main(/*int argc, char *argv[]*/){ horn = Mix_LoadWAV("assets/air-horn-club-sample_1.wav"); // Mix_VolumeMusic(15); // Set the volume - Mix_PlayMusic( music, -1 ); // Play music forever + //Mix_PlayMusic( music, -1 ); // Play music forever /* * Load sprites used in the inventory menu. See src/inventory.cpp @@ -482,6 +482,7 @@ void mainLoop(void){ static unsigned int prevTime = 0, // Used for timing operations currentTime = 0, // prevPrevTime= 0; // + World *prev; if(!currentTime){ // Initialize currentTime if it hasn't been currentTime=millis(); @@ -500,8 +501,15 @@ void mainLoop(void){ /* * Run the logic handler if MSEC_PER_TICK milliseconds have passed. */ - + + prev = currentWorld; ui::handleEvents(); + + if(prev != currentWorld){ + prev->bgmStop(); + currentWorld->bgmPlay(); + } + if(prevPrevTime + MSEC_PER_TICK <= currentTime){ logic(); prevPrevTime = currentTime; |