Beispiel #1
0
    #    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():
        try:
            prop['guid'] = int(prop['guid'])
        except KeyError:
            pass

    props = data.getTilePropertiesByLayer(-1)

    """
    print "GID MAP:"
    for k in sorted(data.gidmap.keys()):
        print "  {}: {}\t{}".format(k,
                                    data.gidmap[k],
Beispiel #2
0
        area.rawGeometry.append(bbox)


    # load the npc's and place them in the default positions 
    npcs = [ p for p in props if p[1].get('group', None) == 'npc' ] 

    for (gid, prop) in npcs:
        pos = data.getTileLocation(gid)
        if len(pos) > 1:
            msg = "control gid: {} is used in more than one locaton"
            raise Exception, msg.format(gid)

        x, y, z = toWorld(data, pos.pop())
        thing = area._parent.getChildByGUID(int(prop['guid']))
        debug("adding thing {} at {}".format(thing, (x, y, z)))
        area.add(thing, (x, y, z))
        #area.setOrientation(thing, "south")


    # load the items and place them where they should go
    # items can have duplicate entries
    items = [ p for p in props if p[1].get('group', None) == 'item' ]
    done = [] 

    for (gid, prop) in items:
        if gid in done: continue
        done.append(gid)

        locations = data.getTileLocation(gid)
        body = area._parent.getChildByGUID(int(prop['guid']))
        copy = False
Beispiel #3
0
        area.rawGeometry.append(bbox)


    # load the npc's and place them in the default positions 
    npcs = [ p for p in props if p[1].get('group', None) == 'npc' ] 

    for (gid, prop) in npcs:
        pos = data.getTileLocation(gid)
        if len(pos) > 1:
            msg = "control gid: {} is used in more than one locaton"
            raise Exception, msg.format(gid)

        x, y, z = toWorld(data, pos.pop())
        thing = area._parent.getChildByGUID(int(prop['guid']))
        debug("adding thing {} at {}".format(thing, (x, y, z)))
        area.add(thing, (x, y, z))
        area.setOrientation(thing, "south")


    # load the items and place them where they should go
    # items can have duplicate entries
    items = [ p for p in props if p[1].get('group', None) == 'item' ]
    done = [] 

    for (gid, prop) in items:
        if gid in done: continue
        done.append(gid)

        locations = data.getTileLocation(gid)
        body = area._parent.getChildByGUID(int(prop['guid']))
        copy = False