71 lines
1.2 KiB
C++
71 lines
1.2 KiB
C++
|
#include "TiledMap.h"
|
||
|
|
||
|
TiledBox::TiledBox()
|
||
|
{
|
||
|
tid=-1;
|
||
|
}
|
||
|
|
||
|
struct TiledMap::impl
|
||
|
{
|
||
|
int l,c;
|
||
|
TiledBox** data;
|
||
|
int rectsize;
|
||
|
|
||
|
int vpline,vpcol;
|
||
|
};
|
||
|
|
||
|
TiledMap::TiledMap(int Line,int Col,int RectSize)
|
||
|
{
|
||
|
sp.reset(new impl);
|
||
|
sp->l=Line;
|
||
|
sp->c=Col;
|
||
|
sp->rectsize=RectSize;
|
||
|
sp->vpline=0;
|
||
|
sp->vpcol=0;
|
||
|
sp->data=new TiledBox*[sp->l];
|
||
|
for(int i=0;i<sp->l;i++)
|
||
|
{
|
||
|
sp->data[i]=new TiledBox[sp->c];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int TiledMap::setBox(int LineID, int ColID, const TiledBox& box)
|
||
|
{
|
||
|
if(LineID>0&&LineID<sp->l&&ColID>0&&ColID<sp->c)
|
||
|
{
|
||
|
sp->data[LineID][ColID]=box;
|
||
|
return 0;
|
||
|
}
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
TiledBox* TiledMap::operator[] (int LineID)
|
||
|
{
|
||
|
return sp->data[LineID];
|
||
|
}
|
||
|
|
||
|
int TiledMap::getRectSize()
|
||
|
{
|
||
|
return sp->rectsize;
|
||
|
}
|
||
|
|
||
|
void TiledMap::setRectSize(int RectSize)
|
||
|
{
|
||
|
if(RectSize<0) RectSize=0;
|
||
|
sp->rectsize=RectSize;
|
||
|
}
|
||
|
|
||
|
void TiledMap::setViewPoint(int Line, int Col)
|
||
|
{
|
||
|
Line=std::min(std::max(Line,0),sp->l);
|
||
|
Col=std::min(std::max(Col,0),sp->c);
|
||
|
sp->vpline=Line;
|
||
|
sp->vpcol=Col;
|
||
|
}
|
||
|
|
||
|
void TiledMap::getViewPoint(int& refLine, int& refCol)
|
||
|
{
|
||
|
refLine=sp->vpline;
|
||
|
refCol=sp->vpcol;
|
||
|
}
|