Ejemplo n.º 1
0
void cEdiPaint::DrawTile( int idx, int x, int y, dword color, int flip, int frame, Blend blend, float scale )
{
	Tile* tile = TileGet(idx); 
	if(tile==NULL) return;

	int w = tile->GetWidth();
	int h = tile->GetHeight();
	if(frame<0) frame=0;
	frame = frame % tile->frames;
	int fx = tile->GetFx(frame);
	int fy = tile->GetFy(frame);
	fRect src(fx * w, fy * h, (fx+1) * w, (fy + 1) * h);
	R9_SetBlend(blend);
	R9_DrawSprite( fV2(x, y), src, tile->tex, color, flip, scale );

}
Ejemplo n.º 2
0
	/*
		returns true or false if it saved----->do something with result to show user
		Saves the map in XML format
		hmmm using standard type members as attributes
		using complex objects members as nodes
		<map attrib1="" attrib2="" attrib3="">
			<tileset>
				<tile attribute1="blah" />
				<tile attribute1="blah" />
				<tile attribute1="blah" />
				<tile attribute1="blah" />
			</tileset>

		</map>
	*/
	bool Map::SaveMap()
	{
		pugi::xml_document xmlDoc;	
		pugi::xml_node xmlMap = xmlDoc.append_child("map");
		xmlMap.append_attribute("width").set_value(width_);
		xmlMap.append_attribute("height").set_value(height_);
		//objectify player soon
		xmlMap.append_attribute("playerplaced").set_value(playerplaced_);
		xmlMap.append_attribute("playerx").set_value(playerStartX_);
		xmlMap.append_attribute("playery").set_value(playerStartY_);
		pugi::xml_node xmlTileSet = xmlMap.append_child("tilevector");
		for(int i = 0; i < tiles_.size(); i++)
		{
			for(int j = 0; j < tiles_[i].size(); j++)
			{
				Tile *currentTile = &tiles_[i][j];
				pugi::xml_node xmlCurrentTile = xmlTileSet.append_child("tile");
				xmlCurrentTile.append_attribute("tiletype").set_value(currentTile->GetTileType());
				xmlCurrentTile.append_attribute("x").set_value(currentTile->GetCurrentPositionX());
				xmlCurrentTile.append_attribute("y").set_value(currentTile->GetCurrentPositionY());
				xmlCurrentTile.append_attribute("clickable").set_value(currentTile->GetClickable());
				xmlCurrentTile.append_attribute("color_a").set_value(currentTile->GetColor().a);
				xmlCurrentTile.append_attribute("color_b").set_value(currentTile->GetColor().b);
				xmlCurrentTile.append_attribute("color_g").set_value(currentTile->GetColor().g);
				xmlCurrentTile.append_attribute("color_r").set_value(currentTile->GetColor().r);
				xmlCurrentTile.append_attribute("height").set_value(currentTile->GetHeight());
				xmlCurrentTile.append_attribute("width").set_value(currentTile->GetWidth());
				xmlCurrentTile.append_attribute("movespeed").set_value(currentTile->GetMoveSpeed());


				if(currentTile->GetHasImage())
				{
					pugi::xml_node xmlCurrentImage = xmlCurrentTile.append_child("image");
					xmlCurrentImage.append_attribute("id").set_value(currentTile->GetObjectImage()->GetId());
				}
			}
		}
		return xmlDoc.save_file(al_path_cstr(mapPath_,'/'));
	}