- added geometry option which allows SuperTux to run at any resolution
[supertux.git] / lib / audio / sound_manager.cpp
index 283fbba..2144bba 100644 (file)
@@ -33,7 +33,8 @@ using namespace SuperTux;
 SoundManager* SoundManager::instance_ = 0;
 
 SoundManager::SoundManager()
-  : current_music(0), m_music_enabled(true) , m_sound_enabled(true) , audio_device(true)
+  : current_music(0), m_music_enabled(true) , m_sound_enabled(true),
+    audio_device(true)
 {
 }
 
@@ -42,8 +43,7 @@ SoundManager::~SoundManager()
   if(audio_device)
     Mix_HaltMusic();
 
-sounds.clear();
-destroy_instance();
+  sounds.clear();
 }
 
 void
@@ -72,7 +72,7 @@ SoundManager::play_sound(Mix_Chunk* sound, const Vector& pos, const Vector& pos2
   // TODO make sure this formula is good
   float distance 
     = pos2.x- pos.x;
-  int loud = int(255.0/float(screen->w*2) * fabsf(distance));
+  int loud = int(255.0/float(SCREEN_WIDTH*2) * fabsf(distance));
   if(loud > 255)
     return;
 
@@ -184,7 +184,8 @@ SoundManager::enable_music(bool enable)
   if(m_music_enabled == false) {
     Mix_HaltMusic();
   } else {
-    Mix_PlayMusic(current_music->music, -1);
+    if(current_music)
+      Mix_PlayMusic(current_music->music, -1);
   }
 }