import pygame
import os

class Load:
    """class Load
    this class is for load all the resources the images and the music
    in the game"""   
        
    #functions to create our resources
    def load_image(self, name, colorkey=None):
        """load_image(self, name, colorkey=None)
        name = string  name of the image
        colorkey = float  transparenci of the image
        returns -> a image and a rect object for the image """
        fullname = os.path.join('images', name)
        try:
            image = pygame.image.load(fullname)
        except pygame.error, message:
            print 'Cannot load image:', fullname
            raise SystemExit, message
        image = image.convert()
        return image 
    

    def load_sound(self, name):
        """load_sound(self, name)
        name = string  the name of the sound 
        returns -> a sound"""
        class NoneSound:
            def play(self): pass
        if not pygame.mixer or not pygame.mixer.get_init():
            return NoneSound()
        fullname = os.path.join('sounds', name)
        try:
            sound = pygame.mixer.Sound(fullname)
        except pygame.error, message:
            print 'Cannot load sound:', fullname
            raise SystemExit, message
        return sound
        
