本文整理汇总了C++中TileMap::GetTileSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TileMap::GetTileSize方法的具体用法?C++ TileMap::GetTileSize怎么用?C++ TileMap::GetTileSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileMap
的用法示例。
在下文中一共展示了TileMap::GetTileSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void TiledBackground::Render()
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPushMatrix();
Camera *camera = m_viewCtrl->GetCamera();
if(camera)
{
game2d::PhysicalObject *focus = camera->GetFocus();
{
Vector2<float> focusPosition = focus->GetPosition();
Vector2<float> focusExtent = focus->GetExtent();
Vector2<float> viewScale = m_viewCtrl->GetViewScale();
Vector2<int> viewExtent = m_viewCtrl->GetExtent();
glPushMatrix();
Vector2<float> half((float)viewExtent[0] / 2.f, (float)viewExtent[1] / 2.f);
Vector2<float> focusHalf = focusExtent / 2.f;
glTranslatef(half[0] - viewScale[0] * focusPosition[0], half[1] - viewScale[1] * focusPosition[1], 0.f);
// glTranslatef(half[0] - m_viewScale[0] * (focusPosition[0] + focusHalf[0]), half[1] - m_viewScale[1] * (focusPosition[1] + focusHalf[1]), 0.f);
glScalef(viewScale[0], viewScale[1], 1.f);
float minX, minY, maxX, maxY;
minX = ((focusPosition[0] + focusHalf[0]) - half[0] / viewScale[0]);
minY = ((focusPosition[1] + focusHalf[1]) - half[1] / viewScale[1]);
maxX = ((focusPosition[0] + focusHalf[0]) + half[0] / viewScale[0]);
maxY = ((focusPosition[1] + focusHalf[1]) + half[1] / viewScale[1]);
for(vector<pair<TileMap *, float> >::iterator it = m_tileMapVec.begin(); it != m_tileMapVec.end(); it++)
{
glPushMatrix();
TileMap *tileMap = it->first;
float scale = it->second;
Vector2<unsigned short> tileSize = tileMap->GetTileSize();
int _minX, _minY, _maxX, _maxY;
_minX = (int)((minX / tileSize[0]) / scale) - 1;
_maxX = (int)((maxX / tileSize[0]) / scale) + 1;
_minY = (int)((minY / tileSize[1]) / scale) - 1;
_maxY = (int)((maxY / tileSize[1]) / scale) + 1;
if(_minX < 0)
_minX = 0;
if(_minY < 0)
_minY = 0;
if(_maxX < 0)
_maxX = 0;
if(_maxY < 0)
_maxY = 0;
glScalef(scale, scale, 1.f);
tileMap->Render(_minX, _minY, _maxX, _maxY);
glPopMatrix();
}
glPopMatrix();
}
}
glPopMatrix();
glDisable(GL_BLEND);
}