コード例 #1
0
TileMap::TileMap(string sourceFile, ImageManager &ImageManager_)
{
	//Load the XML source file.
	string str = "Data/Arenas/";
	str = str + sourceFile;
	TiXmlDocument ArenaDocument(str.c_str());
	if(!ArenaDocument.LoadFile())
	{
		cerr<<"Error while loading "<<sourceFile<<endl;
		cerr<<ArenaDocument.ErrorDesc()<<endl;
	}
	
	TiXmlHandle ArenaHandle(&ArenaDocument);
	
	//Load the tile set.
	TiXmlNode* TileSetNode = ArenaHandle.FirstChild("Arena").FirstChild("TileSet").ToNode();
	TiXmlElement* TileElement = NULL;
	while(TileSetNode->IterateChildren("Tile", TileElement) != NULL)
	{
		TileElement = TileSetNode->IterateChildren("Tile", TileElement)->ToElement();
		str = "Data/Tiles/";
		str = str + TileElement->Attribute("file");
		TileSet.push_back(Tile(ImageManager_.Get(str)));
		TileSet.back().sourceFile = str;
		if(strcmp(TileElement->Attribute("isBlockingCharacters"),"true") == 0)
		{
			TileSet.back().blocksCharacters = true;
		}
		else
			TileSet.back().blocksCharacters = false;
		if(strcmp(TileElement->Attribute("isBlockingSpells"), "true") == 0)
			TileSet.back().blocksSpells = true;
		else
			TileSet.back().blocksSpells = false;
	}
	
	//Load the tile map.
	TiXmlNode* MapNode = ArenaHandle.FirstChildElement("Arena").FirstChild("Map").ToNode();
	TiXmlElement* Line = NULL;
	string tileLine;
	int temp;
	while(MapNode->IterateChildren("Line", Line) != NULL)
	{
		Line = MapNode->IterateChildren("Line", Line)->ToElement();
		tileLine = Line->Attribute("TileLine");
		Tiles.push_back(vector<int>(tileLine.size()));
		for(int i=0; i<tileLine.size(); i++)
		{
			temp = tileLine.c_str()[i] - '0';
			Tiles.back()[i] = temp;
		}
	}
}
コード例 #2
0
Teleportation::Teleportation(Vector2f Position, ImageManager& ImageManager_)
{
	this->SetImage(*ImageManager_.Get("Data/Spells/SpeedBuff.png"));
	this->SetPosition(Position);
	timeLeft = 50;
}