1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

#include "fsIScroller.h"

#include "fsITileMap.h"

using namespace fsNTileMap;

const fsPoint& fsIScroller::tileOffsetGet() const
{
	return mTileOffest;
}

const fsPoint& fsIScroller::subTileScrollOffsetGet() const
{
	return mSubTileScrollOffest;
}

fsBool fsIScroller::clamp(fsS32& pVal, fsS32 pLow, fsS32 pRange) const<--- The member function 'fsNTileMap::fsIScroller::clamp' can be static.
{
	if (pVal >= (pLow + pRange))
	{
		pVal -= pRange;
		return true;
	}
	else if (pVal < pLow)
	{
		pVal += pRange;
		return true;
	}
	return false;
}

void fsIScroller::tileOffsetSet(const fsPoint& pOffest)
{
	mTileOffest = pOffest;
	mTileOffest.x /= mMap->tileWidthGet();
	mTileOffest.y /= mMap->tileHeightGet();
}

fsBool fsIScroller::fullTileScrollHandleX(fsS32& pAttemptedX, fsS32 pViewWidth)
{
	return tileWrap(mSubTileScrollOffest.x, pAttemptedX, mTileOffest.x, mMap->tileWidthGet(),  mMap->widthGet() - pViewWidth);
}

fsBool fsIScroller::fullTileScrollHandleY(fsS32& pAttemptedY, fsS32 pViewHeight)
{
	return tileWrap(mSubTileScrollOffest.y, pAttemptedY, mTileOffest.y, mMap->tileHeightGet(),  mMap->heightGet() - pViewHeight);
}

void fsIScroller::tileMapSet(fsITileMap* const pMap)
{
	mMap = pMap;
}

fsIScroller::fsIScroller() :
mTileOffest(0, 0),
mSubTileScrollOffest(0, 0),
mMap(nullptr)
{
}