Example #1
0
        def getMapOffset(mapid): return mapid%3*100, mapid//3*100
        def linkside(mapid, direction, bothway, sidelen=30):
                tx, ty = getMapOffset(mapid)
                if direction == pygame.K_LEFT:
                        for i in range(sidelen): mapManager.addLink((mx, my+i), direction, (tx+sidelen-1, ty+i), bothway)
                elif direction == pygame.K_RIGHT:
                        for i in range(sidelen): mapManager.addLink((mx+sidelen-1, my+i), direction, (tx, ty+i), bothway)
                elif direction == pygame.K_UP:
                        for i in range(sidelen): mapManager.addLink((mx+i, my), direction, (tx+i, ty+sidelen-1), bothway)
                elif direction == pygame.K_DOWN:
                        for i in range(sidelen): mapManager.addLink((mx+i, my+sidelen-1), direction, (tx+i, ty), bothway)
                else:
                        raise ValueError(direction)

        terrain = base.init_terrain(os.path.join("maps", "Map1", "1402438776.terrain"), "myTexture.texture", True, textureSize)
        terrain.readTextureFromSurface(pygame.image.load(os.path.join("maps", "Map1", "1402438776.jpeg")))
        terrain.readTerrainProperty(os.path.join("maps", "Map1", "1402965027.terrainProperty"))
        mx, my = getMapOffset(0)
        mapManager.add(maps.Map(terrain, (mx, my),typ=maps.MAP_TYPE_GRASS))
        linkside(1, pygame.K_RIGHT, True, 30)
        linkside(3, pygame.K_DOWN, True, 30)

        terrain = base.init_terrain(os.path.join("maps", "Map2", "1402359981.terrain"), "myTexture.texture", True, textureSize)
        terrain.readTextureFromSurface(pygame.image.load(os.path.join("maps", "Map2", "1402359981.jpeg")))
        terrain.readTerrainProperty(os.path.join("maps", "Map2", "1402601113.terrainProperty"))
        mx, my = getMapOffset(1)
        mapManager.add(maps.Map(terrain, (mx, my), typ=maps.MAP_TYPE_GRASS))
        linkside(2, pygame.K_RIGHT, True, 30)

        terrain = base.init_terrain(os.path.join("maps", "Map3", "1402437430.terrain"), "myTexture.texture", True, textureSize)
Example #2
0
def LoadMap(uPos):
    global g_cm, world, terrain
    g_cm = mapManager.getMap(uPos)
    world = g_cm.world
    terrain = g_cm.terrain


evt = rgine.Event()
wm = rgine.windows.WindowsManager(ScreenSize)

maps.init(ScreenSize, textureSize)
mapManager = maps.MapManager()
for i in base.maps:
    mapManager.add(maps.Map(*i))

terrain = base.init_terrain("1399339488.terrain", "myTexture.texture", True,
                            textureSize)
terrain.readTextureFromSurface(pygame.image.load("1399339488.jpeg"))
terrain.readTextureProperty("1399648062.textureProperty")
terrain.setProperty(0, 1, 255)
terrain.setProperty(1, 0, 255)
mapManager.add(maps.Map(terrain, (4, 4)))

pManager = base.PlayerManager(libpkmon.player, terrain, base.playerEvent,
                              base.npcs)
pManager.getPlayer().setPos(5 + 4, 10 + 4)

LoadMap(pManager.getPlayer().getPos())

npcManager = base.NPCManager()
for i in base.npcs:
    npcManager.new(i[0], i[1], base.npcs[i])
Example #3
0
def LoadMap(uPos):
	global g_cm, world, terrain
	g_cm = mapManager.getMap(uPos)
	world = g_cm.world
	terrain = g_cm.terrain

evt = rgine.Event()
wm = rgine.windows.WindowsManager(ScreenSize)

maps.init(ScreenSize, textureSize)
mapManager = maps.MapManager()
for i in base.maps:
	mapManager.add(maps.Map(*i))

terrain = base.init_terrain("1399339488.terrain", "myTexture.texture", True, textureSize)
terrain.readTextureFromSurface(pygame.image.load("1399339488.jpeg"))
terrain.readTextureProperty("1399648062.textureProperty")
terrain.setProperty(0, 1, 255)
terrain.setProperty(1, 0, 255)
mapManager.add(maps.Map(terrain, (4, 4)))

pManager = base.PlayerManager(libpkmon.player, terrain, base.playerEvent, base.npcs)
pManager.getPlayer().setPos(5+4, 10+4)

LoadMap(pManager.getPlayer().getPos())

npcManager = base.NPCManager()
for i in base.npcs:
	npcManager.new(i[0], i[1], base.npcs[i])