Beispiel #1
0
void TileMap::LoadMap()
{
    printf("Loading Tiled Map File At: %s \n", tiledPath.c_str());
    
    jMap = ReadJSONFile(tiledPath);
    
    /* Init Variables */
    
    tilewidth = jMap["tilewidth"].asInt(); //Defines Width of Tile in pixels
    tileheight = jMap["tileheight"].asInt(); //Defines Height of Tile in pixels
    
    width = jMap["width"].asInt(); //Defines Width Of Tilemap in tiles
    height = jMap["height"].asInt(); //Defines Width Of Tilemap in tiles
    
    //dRect.w = tilewidth; //Sets rendering rectange width to width of tile
    //dRect.h = tileheight; //Sets rendering rectange height to height of tile
    
    const Json::Value jLayers = jMap["layers"]; //Get's all tile map layers
    for (int i=0; i<jLayers.size(); i++) //Loops thorught each tile map layer
    {
        mapLayers.push_back(new int[width*height]); //Adds layer map to Layers List
        
        const Json::Value jLayer = jLayers[i]["data"]; //Get's layer data
        for (int a=0; a<jLayer.size(); a++) //Loop to copy data from json layer to array of integers
        {
            mapLayers[i][a] = jLayer[a].asInt();
            
            if (mapLayers[i][a] == 17)
            {
                mapLayers[i][a] = 0;
                
                Enemy* en = new Enemy("PlatformerTiles",32,32);
                en->animS.r = 1;
                en->position = Vector2(a%width*tilewidth,a/width*tileheight);
                
                enemies.push_back(en);
            }
        }
    }
}
Beispiel #2
0
CScriptVal CComponentManager::Script_ReadCivJSONFile(void* cbdata, std::wstring fileName)
{
	return ReadJSONFile(cbdata, L"civs", fileName);
}
Beispiel #3
0
CScriptVal CComponentManager::Script_ReadJSONFile(void* cbdata, std::wstring fileName)
{
	return ReadJSONFile(cbdata, L"simulation/data", fileName);
}
Beispiel #4
0
CScriptVal CComponentManager::Script_ReadCivJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring fileName)
{
	return ReadJSONFile(pCxPrivate, L"civs", fileName);
}
Beispiel #5
0
CScriptVal CComponentManager::Script_ReadJSONFile(ScriptInterface::CxPrivate* pCxPrivate, std::wstring fileName)
{
	return ReadJSONFile(pCxPrivate, L"simulation/data", fileName);
}
Beispiel #6
0
JS::Value CComponentManager::Script_ReadCivJSONFile(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& fileName)
{
	return ReadJSONFile(pCxPrivate, L"simulation/data/civs", fileName);
}