Example #1
0
def readWorld(tagMap):
    world = World()
    tagMap = tagMap.data
    tagSpriteArray = tagMap["spirtes"].data
    for tagSprite in tagSpriteArray:
        spr = WorldSprite.tagToSprite(tagSprite)
        if(spr.background):
            world.backgrounds.append(spr)
        else:
            world.foregrounds.append(spr)
        if(spr.collisions):
            world.clips.append(spr)
        if(spr.trigger):
            world.triggers.append(spr)
    tagPlayerSpawns = tagMap["playerSpawns"].data
    for tagPlayerSpawn in tagPlayerSpawns:
        world.playerSpawns.append([((tagPlayerSpawn.data>>16)&65535)-400, ((tagPlayerSpawn.data>>16)&65535)-400])
    tagMobSpawns = tagMap["mobSpawns"].data
    for tagMobSpawn in tagMobSpawns:
        world.mobSpawns.append([((tagMobSpawn.data>>16)&65535)-400, ((tagMobSpawn.data>>16)&65535)-400])
    
    tagCrateSpawnZones = tagMap["crateSpawnZones"].data
    for tagCrateSpawnZone in tagCrateSpawnZones:
        zoneAr = tagCrateSpawnZone.data
        world.crateSpawnZones.append([zoneAr[0].data, zoneAr[1].data, zoneAr[2].data, zoneAr[3].data])
    
    world.gravity = tagMap["gravity"].data
    world.enemySpawnDelay = tagMap["enemySpawnDelay"].data
    return world
Example #2
0
def readWorld(tagMap):
    world = World()
    tagMap = tagMap.data
    tagSpriteArray = tagMap["spirtes"].tags
    for tagSprite in tagSpriteArray:
        spr = WorldSprite.tagToSprite(tagSprite)
        if(spr.background):
            world.backgrounds.append(spr)
        else:
            world.foregrounds.append(spr)
        if(spr.collisions):
            world.clips.append(spr)
        if(spr.trigger):
            world.triggers.append(spr)
    tagPlayerSpawns = tagMap["playerSpawns"].tags
    for tagPlayerSpawn in tagPlayerSpawns:
        world.playerSpawns.append([tagPlayerSpawn.tags[0].i, tagPlayerSpawn.tags[1].i])
    
    tagMobSpawns = tagMap["mobSpawns"].tags
    for tagMobSpawn in tagMobSpawns:
        world.mobSpawns.append([tagMobSpawn.tags[0].i, tagMobSpawn.tags[1].i])
        
    tagMobSpawns = tagMap["mobSpawns"].tags
    for tagMobSpawn in tagMobSpawns:
        world.mobSpawns.append([tagMobSpawn.tags[0].i, tagMobSpawn.tags[1].i])
        
    tagCrateSpawnZones = tagMap["crateSpawnPoints"].tags
    for tagCrateSpawnZone in tagCrateSpawnZones:
        zoneAr = tagCrateSpawnZone.tags
        world.crateSpawnZones.append(pygame.Rect(zoneAr[0].i, zoneAr[1].i, zoneAr[2].i, zoneAr[3].i))
    
    world.gravity = tagMap["gravity"].float
    world.enemySpawnDelay = tagMap["enemySpawnDelay"].i
    return world