def loadFonts():
    main_directory = ServerConnection.getMainDirectory()

    pyglet.resource.path.append(main_directory + '/fonts')
    pyglet.resource.reindex()

    for font in fonts:
        ServerConnection.getClientPath('fonts/'+font)
        pyglet.resource.add_font(font)
def init():
    ServerConnection.createDirectories()
    loadTileset()
    loadObjects()
    loadEnemies()
    loadFonts()

    main_directory = ServerConnection.getMainDirectory()
    pyglet.resource.path.append(main_directory + '/bgm')
    pyglet.resource.reindex()

    ServerConnection.getClientPath('img/gui/gui.png')
    ServerConnection.getClientPath('bgm/main_screen.ogg')
def loadTileset():

    dic = {}

    sql =  "select til_name, til_path, til_type "
    sql += "from tileset "

    rows = DBConnection.getResult(sql)

    tiles =     {   'wall-nw':      (0,3),
                    'wall-n':       (1,3),
                    'wall-ne':      (2,3),
                    'wall-w':       (0,2),
                    'wall-e':       (2,2),
                    'wall-sw':      (0,1),
                    'wall-s':       (1,1),
                    'wall-se':      (2,1),
                    'door-n':       (3,3),
                    'door-s':       (3,2),
                    'ground':       (1,2),
                    'ground-alt1':  (0,0),
                    'ground-alt2':  (1,0),
                    'ground-alt3':  (2,0),
                    'empty':        (3,0)
                }

    for row in rows:

        name = row[0]
        path = row[1]
        type_tileset = row[2]

        if type_tileset == 'room':
            img = ServerConnection.getImage(path)

            tileset = cocos.tiles.TileSet(name, None)
            for n, p in tiles.items():
                prop =  {   'passable': True,
                            'transition' : False
                        }

                if n == 'door-n':
                    prop['transition'] = True

                tileset.add( prop, getTile(img,p), n)
                dic[name] = tileset
        else:
            ServerConnection.getClientPath(path)

    global TILESETS
    TILESETS.update(dic)