Esempio n. 1
0
    This means that the node passed must have all the objects that are
    referenced by the TMX map
    """

    # for platformer maps
    def toWorld(data, (x, y, z)):
        """ translate tiled map coordinates to world coordinates """
        return z, x*data.tilewidth, (y-1)*data.tileheight

    # for zelda-style games
    #def toWorld(data, (x, y, l)):
    #    """ translate tiled map coordinates to world coordinates """
    #    return y*data.tileheight, x*data.tilewidth, l


    area = PlatformArea()
    parent.add(area)
    area.parent = parent
    area.mappath = res.mapPath(mapname)
    data = tmxloader.load_tmx(area.mappath)

    # get sounds from tiles
    for i, layer in enumerate(data.tilelayers):
        props = data.getTilePropertiesByLayer(i)
        for gid, tileProp in props:
            for key, value in tileProp.items():
                if key[4:].lower() == "sound":
                    area.add(Sound(value))


    for gid, prop in data.tile_properties.items():
Esempio n. 2
0
    This body (called parent) must already be connected to the data tree,
    otherwise body loading will not work and area building will fail.
    """

    # for platformer maps
    def toWorld(data, (x, y, z)):
        """ translate tiled map coordinates to world coordinates """
        return z, x*data.tilewidth, (y-1)*data.tileheight

    # for zelda-style games
    #def toWorld(data, (x, y, l)):
    #    """ translate tiled map coordinates to world coordinates """
    #    return y*data.tileheight, x*data.tilewidth, l


    area = PlatformArea()
    parent.add(area)
    area.setParent(parent)
    area.mappath = res.mapPath(mapname)
    data = tmxloader.load_tmx(area.mappath)

    for gid, prop in data.tile_properties.items():
        try:
            prop['guid'] = int(prop['guid'])
        except KeyError:
            pass

    props = data.getTilePropertiesByLayer(-1)

    """
    print "GID MAP:"
Esempio n. 3
0
    This body (called parent) must already be connected to the data tree,
    otherwise body loading will not work and area building will fail.
    """

    # for platformer maps
    def toWorld(data, (x, y, z)):
        """ translate tiled map coordinates to world coordinates """
        return z, x*data.tilewidth, (y-2)*data.tileheight

    # for zelda-style games
    #def toWorld(data, (x, y, l)):
    #    """ translate tiled map coordinates to world coordinates """
    #    return y*data.tileheight, x*data.tilewidth, l


    area = PlatformArea()
    parent.add(area)
    area.setParent(parent)
    area.mappath = res.mapPath(mapname)
    data = tmxloader.load_tmx(area.mappath)


    for gid, prop in data.tile_properties.items():
        try:
            prop['guid'] = int(prop['guid'])
        except KeyError:
            pass

    props = data.getTilePropertiesByLayer(-1)

    """