import os
import pygame.image
+import pygame.font
import pygame.display
+from .constants import DEBUG
+
class Loader(object):
""" Load data files from beneath a prefix. """
path = "/".join(parts)
rel_path = os.path.join(*path.split("/"))
abs_path = os.path.join(self._prefix, rel_path)
- print abs_path
+ if DEBUG:
+ print abs_path
return abs_path
def open_file(self, *parts):
self._cache[fn] = img
return img
+ def load_font(self, *parts, **kwargs):
+ """Return a pygame font of the given size"""
+ size = kwargs.get('size', 12)
+ fn = self.full_path("fonts", *parts)
+ font = pygame.font.Font(fn, size)
+ # Do we need to cache this?
+ return font
+
_DATA_PREFIX = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "data"))