Beispiel #1
0
def main():
    """
    Prepara las ventanas, define modelos, controlador y vista y corre el programa
    :return: void
    """

    # Se obtiene el checksum del juego
    checksum = [path_checksum('lib', VERBOSE),
                md5file('main.py', VERBOSE).upper(),
                path_checksum('bin', VERBOSE)]

    # Se cargan las configuraciones
    control_config = configLoader(DIR_CONFIG + "control.ini", verbose=VERBOSE)
    game_config = configLoader(DIR_CONFIG + "game.ini", verbose=VERBOSE)
    map_config = configLoader(DIR_CONFIG + "map.ini", verbose=VERBOSE)
    score_config = configLoader(DIR_CONFIG + "scoreboard.ini", verbose=VERBOSE)
    user_config = configLoader(DIR_CONFIG + "user.ini", verbose=VERBOSE)
    view_config = configLoader(DIR_CONFIG + "view.ini", verbose=VERBOSE)
    window_config = configLoader(DIR_CONFIG + "window.ini", verbose=VERBOSE)
    world_config = configLoader(DIR_CONFIG + "world.ini", verbose=VERBOSE)

    # Se carga el idioma
    lang = langs.langLoader(game_config.getValue("LANG"))  # @UndefinedVariable

    # Se carga la información de la pantalla del cliente
    display_info = pygame.display.Info()  # @UndefinedVariable

    # Se comprueba que el nombre de jugador no sea Player, si no es valido se pide uno nuevo
    if not username.validate(
            user_config.getValue("NAME")):  # @UndefinedVariable
        new_name = username.request(lang.get(111),
                                    lang.get(112))  # @UndefinedVariable
        if new_name is not username.NO_VALID_NAME:  # @UndefinedVariable
            user_config.setParameter("NAME", new_name)
            user_config.export()
        else:
            utils.destroyProcess()  # @UndefinedVariable

    # Creación de ventana
    window = Window(window_config, lang.get(10),
                    pygame.image.load(getIcons("icon")),
                    display_info)  # @UndefinedVariable
    clock = pygame.time.Clock()  # reloj @UndefinedVariable
    fps = int(game_config.getValue("FPS"))  # fps a dibujar

    # Se crea el mundo
    world = World(world_config, map_config, window, checksum, score_config,
                  user_config, lang, game_config, verbose=VERBOSE)
    # TEST: world.loadMap(1)

    # Se crean los menús de inicio y pause
    menus = Createuimenu(lang, window, world, game_config, user_config,
                         view_config, window_config, world_config, map_config)

    # Se crea la vista
    vista = View(window, clock, world, lang, view_config, menus)
    menus.addView(vista)

    # Se crea el controlador
    control = Controller(world, clock, lang, control_config, window, menus,
                         verbose=VERBOSE)
    menus.addController(control)
    vista.add_controller(control)

    # Se lanza el mainloop
    while True:
        clock.tick(fps)
        vista.draw(control.event_loop())
Beispiel #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Clases del juego
# Permite administrar las clases lógicas del juego
# Las librerías auxiliares o que no pertenecen a la lógica van en /bin

# Game template
# Autor: PABLO PIZARRO @ ppizarro ~
# Fecha: ABRIL 2015

# Configuración de entorno
from bin import configLoader
import libdir
from path import *

# noinspection PyProtectedMember
__binconfig = configLoader(libdir._LIB_CONFIG + "lib.ini")