コード例 #1
0
ファイル: world.py プロジェクト: ppizarror/Ned-For-Spod
 def load_sound(self, sound_file):
     """
     Carga un sonido
     :param sound_file: Archivo de sonido
     :return: Sonido
     """
     try:
         if self.verbose:
             print self.langs.get(52, sound_file)
         return pygame.mixer.Sound(getSounds(sound_file))
     except:
         if self.verbose:
             print self.langs.get(53, self.langs.get(54, sound_file))
         return pygame.mixer.Sound()
コード例 #2
0
ファイル: uimenu.py プロジェクト: ppizarror/Ned-For-Spod
    def __init__(self, langs, window, world, game_config, user_config,
                 view_config, window_config, world_config, map_config):
        """
        Función constructora
        :param langs: Diccionario de idioma
        :param window: Ventana de la aplicación
        :param world: Objeto mundo
        :param game_config: Configuraciones del juego
        :param user_config: Configuraciones de usuario
        :param view_config: Configuraciones de la vista
        :param window_config: Configuraciones de la ventana
        :param world_config: Configuraciones del mundo
        :param map_config: Configuraciones del mapa
        :return: void
        """

        # Variables de clase
        self.config_game = game_config  # configuraciones del juego
        self.config_map = map_config  # configuracion del mapa
        self.config_user = user_config  # configuraciones de usuario
        self.config_view = view_config  # configuraciones de la vista
        self.config_window = window_config  # configuraciones de la ventana
        self.config_world = world_config  # configuraciones del mundo
        self.controller = None  # controlador
        self.font = getFonts("menu")  # se obtiene la fuente por defecto
        self.langs = langs  # idiomas del juego
        self.menu_inicial_title_font = pygame.font.Font(getFonts("nfs"), 55)
        self.screen = window.get_surface()  # se obtiene la superficie de dibujo
        self.sound_state = game_config.isTrue(
            "ENABLESOUND")  # define si los sonidos estan activos
        self.view = None  # vista
        self.window = window  # ventana de visualización
        self.world = world  # mundo
        # Canales de sonido de los menues
        self.menuSoundChannel = pygame.mixer.Channel(4)
        self.menuSoundChannel.set_volume(
            float(self.config_world.getValue("CHANNEL_4")))
        self.menuButtonChannel = pygame.mixer.Channel(5)
        self.menuSoundChannel.set_volume(
            float(self.config_world.getValue("CHANNEL_5")))
        # Sonido de fondo del menu de inicio
        self.menu_inicial_sfx = pygame.mixer.Sound(getSounds("intro"))
        self.menu_button_up = pygame.mixer.Sound(getSounds("down"))
        self.menu_button_down = pygame.mixer.Sound(getSounds("up"))
        # Se renderiza la fuente del titulo
        self.menu_inicial_title = self.menu_inicial_title_font.render(
            self.langs.get(10), 1, (255, 255, 255))
        self.menu_inicial_title_shadow = self.menu_inicial_title_font.render(
            self.langs.get(10), 1, (0, 0, 0))
        self.menu_inicial_title_shadow_width = \
            self.menu_inicial_title_shadow.get_size()[0]
        self.menu_inicial_title_width = self.menu_inicial_title.get_size()[0]
        self.menu_inicial_title_shadow_pos = (
            self.window.get_window_width() / 2 - self.menu_inicial_title_shadow_width / 2 - 3,
            (self.window.get_window_height() - 400) / 2 - 70)
        self.menu_inicial_title_pos = (
            self.window.get_window_width() / 2 - self.menu_inicial_title_width / 2,
            (self.window.get_window_height() - 400) / 2 - 65)
        # Menues
        self.actualmenu = None
        self.menu_inicial = None
        self.menu_jugar = None
        self.menu_pausa = None
        # Se crean los menues
        self.intializeMenuInicial()
        self.setActualMenu(MENU_INICIAL)
        self.initializeMenuPausa()
        # Se crean las imagenes de fondo
        self.splashimages = []
        for key in range(1, 11):
            image = pygame.transform.scale(
                pygame.image.load(getImages("splash" + str(key))),
                (window.get_window_width(), window.get_window_height()))
            self.splashimages.append(image)
        # Tiempos de efectos visuales de fondo
        self.splashindex = 0
        self.splashmaxtime = 0
        self.splashtime = 0
コード例 #3
0
    def __init__(self, langs, window, world, game_config, user_config,
                 view_config, window_config, world_config, map_config):
        """
        Función constructora
        :param langs: Diccionario de idioma
        :param window: Ventana de la aplicación
        :param world: Objeto mundo
        :param game_config: Configuraciones del juego
        :param user_config: Configuraciones de usuario
        :param view_config: Configuraciones de la vista
        :param window_config: Configuraciones de la ventana
        :param world_config: Configuraciones del mundo
        :param map_config: Configuraciones del mapa
        :return: void
        """

        # Variables de clase
        self.config_game = game_config  # configuraciones del juego
        self.config_map = map_config  # configuracion del mapa
        self.config_user = user_config  # configuraciones de usuario
        self.config_view = view_config  # configuraciones de la vista
        self.config_window = window_config  # configuraciones de la ventana
        self.config_world = world_config  # configuraciones del mundo
        self.controller = None  # controlador
        self.font = getFonts("menu")  # se obtiene la fuente por defecto
        self.langs = langs  # idiomas del juego
        self.menu_inicial_title_font = pygame.font.Font(getFonts("nfs"), 55)
        self.screen = window.get_surface(
        )  # se obtiene la superficie de dibujo
        self.sound_state = game_config.isTrue(
            "ENABLESOUND")  # define si los sonidos estan activos
        self.view = None  # vista
        self.window = window  # ventana de visualización
        self.world = world  # mundo
        # Canales de sonido de los menues
        self.menuSoundChannel = pygame.mixer.Channel(4)
        self.menuSoundChannel.set_volume(
            float(self.config_world.getValue("CHANNEL_4")))
        self.menuButtonChannel = pygame.mixer.Channel(5)
        self.menuSoundChannel.set_volume(
            float(self.config_world.getValue("CHANNEL_5")))
        # Sonido de fondo del menu de inicio
        self.menu_inicial_sfx = pygame.mixer.Sound(getSounds("intro"))
        self.menu_button_up = pygame.mixer.Sound(getSounds("down"))
        self.menu_button_down = pygame.mixer.Sound(getSounds("up"))
        # Se renderiza la fuente del titulo
        self.menu_inicial_title = self.menu_inicial_title_font.render(
            self.langs.get(10), 1, (255, 255, 255))
        self.menu_inicial_title_shadow = self.menu_inicial_title_font.render(
            self.langs.get(10), 1, (0, 0, 0))
        self.menu_inicial_title_shadow_width = \
            self.menu_inicial_title_shadow.get_size()[0]
        self.menu_inicial_title_width = self.menu_inicial_title.get_size()[0]
        self.menu_inicial_title_shadow_pos = (
            self.window.get_window_width() / 2 -
            self.menu_inicial_title_shadow_width / 2 - 3,
            (self.window.get_window_height() - 400) / 2 - 70)
        self.menu_inicial_title_pos = (
            self.window.get_window_width() / 2 -
            self.menu_inicial_title_width / 2,
            (self.window.get_window_height() - 400) / 2 - 65)
        # Menues
        self.actualmenu = None
        self.menu_inicial = None
        self.menu_jugar = None
        self.menu_pausa = None
        # Se crean los menues
        self.intializeMenuInicial()
        self.setActualMenu(MENU_INICIAL)
        self.initializeMenuPausa()
        # Se crean las imagenes de fondo
        self.splashimages = []
        for key in range(1, 11):
            image = pygame.transform.scale(
                pygame.image.load(getImages("splash" + str(key))),
                (window.get_window_width(), window.get_window_height()))
            self.splashimages.append(image)
        # Tiempos de efectos visuales de fondo
        self.splashindex = 0
        self.splashmaxtime = 0
        self.splashtime = 0