aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-12-03 16:30:08 -0500
committerClyne Sullivan <tullivan99@gmail.com>2015-12-03 16:30:08 -0500
commitdcd2d1e9ed9df2b67a48acc442c9e816b677b208 (patch)
treebb9da022908f71323bde29ad8787adf097f3b725 /main.cpp
parent67803d1c1ef1bb96a6cdfdfecba943378e0ec5d1 (diff)
moving music to world
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index fb07b38..1ce6049 100644
--- a/main.cpp
+++ b/main.cpp
@@ -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;