Sketch in sound support
[tabakrolletjie.git] / tabakrolletjie / loader.py
index 252960b42b90e9850206dc215d3a8a8e551c24b4..7f012a0f0375ef525f16a265cbd17e7291ddaec5 100644 (file)
@@ -6,6 +6,7 @@ import os
 import pygame.image
 import pygame.font
 import pygame.display
+import pygame.mixer
 
 from .constants import DEBUG
 
@@ -52,6 +53,15 @@ class Loader(object):
         # Do we need to cache this?
         return font
 
+    def load_sound(self, *parts):
+        """Return a pygame sound"""
+        fn = self.full_path("sounds", *parts)
+        sound = self._cache.get(fn, None)
+        if not sound:
+            sound = pygame.mixer.Sound(fn)
+            self._cache[fn] = sound
+        return sound
+
 
 _DATA_PREFIX = os.path.abspath(
     os.path.join(os.path.dirname(__file__), "..", "data"))