예제 #1
0
파일: buildworld.py 프로젝트: bitcraft/mh
# build the initial environment
uni = Environment()
uni.name = 'MH'
uni.setGUID(0)

# build our avatars and heros
avatar = Avatar()
ani = Animation("warrior-male-stand.png", "stand", 1, 4)
avatar.add(ani)
ani = Animation("warrior-male-walk.png", "walk", [0,1,2,1], 4)
avatar.add(ani)
ani = Animation("warrior-male-attack.png", "attack", 4, 4, 60)
avatar.add(ani)
avatar.play("walk")
npc = Hero()
npc.setName("Rat")
npc.setAvatar(avatar)
npc.setGUID(1)
uni.add(npc)


avatar = Avatar()
ani = Animation("townfolk-male-walk.png", "walk", [0,1,2,1], 4)
avatar.add(ani)
npc = NPC()
npc.setName("Mayor")
npc.setAvatar(avatar)
npc.setGUID(2)
uni.add(npc)
예제 #2
0
파일: world.py 프로젝트: MacLeek/mh
def build():
    # build the initial environment
    uni = GameObject()
    uni.name = 'MH'
    uni.setGUID(0)

    # build our avatars and heros
    avatar = Avatar()
    ani = Animation("warrior-male-stand.png", "stand", 1, 4)
    avatar.add(ani)
    ani = Animation("warrior-male-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    ani = Animation("warrior-male-attack.png", "attack", 4, 4, 60)
    avatar.add(ani)
    avatar.play("walk")
    npc = Hero()
    npc.setName("Rat")
    npc.setAvatar(avatar)
    npc.setGUID(1)
    uni.add(npc)

    avatar = Avatar()
    ani = Animation("townfolk-male-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Mayor")
    npc.setAvatar(avatar)
    npc.setGUID(2)
    uni.add(npc)

    avatar = Avatar()
    ani = Animation("ranger-male-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Bolt")
    npc.setAvatar(avatar)
    npc.setGUID(3)
    uni.add(npc)

    avatar = Avatar()
    ani = Animation("healer-male-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Ax")
    npc.setAvatar(avatar)
    npc.setGUID(4)
    uni.add(npc)

    avatar = Avatar()
    ani = Animation("healer-female-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Tooth")
    npc.setAvatar(avatar)
    npc.setGUID(5)
    uni.add(npc)

    avatar = Avatar()
    ani = Animation("magician-male-walk.png", "walk", [0, 1, 2, 1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Nail")
    npc.setAvatar(avatar)
    npc.setGUID(6)
    uni.add(npc)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "barrel", (9, 1), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = True
    item.setName("Barrel")
    item.setAvatar(avatar)
    item.setGUID(513)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "sign", (11, 1), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Sign")
    item.setAvatar(avatar)
    item.setGUID(514)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "rock", (8, 9), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = True
    item.setName("Rock")
    item.setAvatar(avatar)
    item.setGUID(515)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8, 7), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(516)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8, 7), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(517)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8, 7), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(518)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8, 7), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(519)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8, 7), (16, 16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(520)
    uni.add(item)

    # build the areas to explore

    village = fromTMX(uni, "village.tmx")
    village.setName("Village")
    village.setGUID(5001)

    return uni

    home = FromTMX(uni, "building0.tmx")
    home.setName("Building0")
    home.setGUID(5002)

    # finialize exits by adding the needed references

    allAreas = [i for i in uni.getChildren() if isinstance(i, AbstractArea)]
    allExits = defaultdict(list)

    # make table of all exits
    for area in allAreas:
        for guid in area.exits.keys():
            allExits[guid].append(area)

    # set the exits properly
    for guid, areaList in allExits.items():
        if len(areaList) == 2:
            areaList[0].exits[guid] = (areaList[0].exits[guid][0],
                                       areaList[1].guid)
            areaList[1].exits[guid] = (areaList[1].exits[guid][0],
                                       areaList[0].guid)

    return uni
예제 #3
0
파일: world.py 프로젝트: MacLeek/mh
def build():
    # build the initial environment
    uni = GameObject()
    uni.name = 'MH'
    uni.setGUID(0)

    # build our avatars and heros
    avatar = Avatar()
    ani = Animation("warrior-male-stand.png", "stand", 1, 4)
    avatar.add(ani)
    ani = Animation("warrior-male-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    ani = Animation("warrior-male-attack.png", "attack", 4, 4, 60)
    avatar.add(ani)
    avatar.play("walk")
    npc = Hero()
    npc.setName("Rat")
    npc.setAvatar(avatar)
    npc.setGUID(1)
    uni.add(npc)


    avatar = Avatar()
    ani = Animation("townfolk-male-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Mayor")
    npc.setAvatar(avatar)
    npc.setGUID(2)
    uni.add(npc)


    avatar = Avatar()
    ani = Animation("ranger-male-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Bolt")
    npc.setAvatar(avatar)
    npc.setGUID(3)
    uni.add(npc)


    avatar = Avatar()
    ani = Animation("healer-male-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Ax")
    npc.setAvatar(avatar)
    npc.setGUID(4)
    uni.add(npc)


    avatar = Avatar()
    ani = Animation("healer-female-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Tooth")
    npc.setAvatar(avatar)
    npc.setGUID(5)
    uni.add(npc)


    avatar = Avatar()
    ani = Animation("magician-male-walk.png", "walk", [0,1,2,1], 4)
    avatar.add(ani)
    npc = NPC()
    npc.setName("Nail")
    npc.setAvatar(avatar)
    npc.setGUID(6)
    uni.add(npc)


    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "barrel", (9,1), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = True
    item.setName("Barrel")
    item.setAvatar(avatar)
    item.setGUID(513)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "sign", (11,1), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Sign")
    item.setAvatar(avatar)
    item.setGUID(514)
    uni.add(item) 

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "rock", (8,9), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = True
    item.setName("Rock")
    item.setAvatar(avatar)
    item.setGUID(515)
    uni.add(item) 

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(516)
    uni.add(item) 

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(517)
    uni.add(item) 

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(518)
    uni.add(item) 

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(519)
    uni.add(item)

    avatar = Avatar()
    ani = StaticAnimation("16x16-forest-town.png", "stump", (8,7), (16,16))
    avatar.add(ani)
    item = AvatarObject()
    item.pushable = False
    item.setName("Stump")
    item.setAvatar(avatar)
    item.setGUID(520)
    uni.add(item)



    # build the areas to explore

    village = fromTMX(uni, "village.tmx")
    village.setName("Village")
    village.setGUID(5001)


    return uni

    home = FromTMX(uni, "building0.tmx")
    home.setName("Building0")
    home.setGUID(5002)


    # finialize exits by adding the needed references

    allAreas = [ i for i in uni.getChildren() if isinstance(i, AbstractArea) ]
    allExits = defaultdict(list)

    # make table of all exits
    for area in allAreas:
        for guid in area.exits.keys():
            allExits[guid].append(area)

    # set the exits properly
    for guid, areaList in allExits.items():
        if len(areaList) == 2:
            areaList[0].exits[guid] = (areaList[0].exits[guid][0], areaList[1].guid)
            areaList[1].exits[guid] = (areaList[1].exits[guid][0], areaList[0].guid)


    return uni