//Translates any screen position to the tile position (in world coordinates) that it belongs
iPoint j1Map::GetTileWorld(int x, int y) const
{
	// NOTE : this maybe can be better applied anywhere else
	iPoint ret(x, y);

	ret = WorldToMap(ret.x, ret.y);
	ret = MapToWorld(ret.x, ret.y);

	return ret;
}
示例#2
0
RECT CGameMap::GetBlockArea( RECT rcCollision )const
{
	RECT ret, rc = WorldToMap( rcCollision );

	ret.left	= int( ( rc.left + ( m_nBlockSizeX >> 1 ) )*m_InvBW );
	ret.top		= int( ( rc.top + ( m_nBlockSizeY >> 1) )*m_InvBH );

	ret.right	= int( (rc.right - rc.left)*m_InvBW + ret.left );
	ret.bottom	= int( (rc.bottom - rc.top)*m_InvBH + ret.top );

	return ret;
}
bool j1Map::IsAtTileCenter(int x, int y) const
{
	iPoint tmp(x, y);
	iPoint center = WorldToMap(x, y);
	center = GetTileCenter(center.x, center.y);

	if (tmp == center)
	{
		return true;
	}
	
	return false;
}