本文整理汇总了C++中Alignment::getY方法的典型用法代码示例。如果您正苦于以下问题:C++ Alignment::getY方法的具体用法?C++ Alignment::getY怎么用?C++ Alignment::getY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alignment
的用法示例。
在下文中一共展示了Alignment::getY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isCollision
bool PixelMap::isCollision(const RectMap &rectmap, const IntPoint &pos1, const IntPoint &pos2, const IntRect &rect1, const IntRect &rect2, const Alignment &alignment1, const Alignment &alignment2) const
{
IntPoint corner1(pos1), corner2(pos2);
IntRect framerect1, framerect2;
IntRect mrect1, mrect2;
IntRect *cutrect;
/* Break */
if(map == NULL)
return false;
/* Translate negative axises */
mrect1 = rect_translate_negative_axises(rect1, size);
mrect2 = rect_translate_negative_axises(rect2, rectmap.getSize());
/* Align */
if(alignment1.getX() != 0) corner1.decX((int)(mrect1.getWidth() * alignment1.getX()));
if(alignment1.getY() != 0) corner1.decY((int)(mrect1.getHeight() * alignment1.getY()));
if(alignment2.getX() != 0) corner2.decX((int)(mrect2.getWidth() * alignment2.getX()));
if(alignment2.getY() != 0) corner2.decY((int)(mrect2.getHeight() * alignment2.getY()));
/* Framerects */
framerect1.load(corner1.getX(), corner1.getY(), mrect1.getWidth(), mrect1.getHeight());
framerect2.load(corner2.getX(), corner2.getY(), mrect2.getWidth(), mrect2.getHeight());
/* Break */
if(!size_to_rect(size).isCovering(mrect1))
throw Exception() << "pixelmap1 doesn't fully cover rect";
/* Cutrect */
if((cutrect = framerect1.getCutrect(framerect2)) == NULL)
return false;
/* Iterate rects, check pixels */
for(int r = 0; r < rectmap.getRectCount(); r++)
{
int fpx, fpy; /* First pixel to check */
int lpx, lpy; /* Last pixel to check */
IntRect srect = rectmap.getRect(r) + point_to_vector(corner2) - IntVector(mrect2.getX(), mrect2.getY());
IntRect *scutrect;
/* Clip with cutrect*/
if((scutrect = srect.getCutrect(*cutrect)) == NULL)
continue;
/* Pixels to check */
fpx = scutrect->getX() - (corner1.getX() - mrect1.getX());
fpy = scutrect->getY() - (corner1.getY() - mrect1.getY());
lpx = fpx + scutrect->getWidth() - 1;
lpy = fpy + scutrect->getHeight() - 1;
/* Check pixels */
for(int py = fpy; py <= lpy; py++)
{
for(int px = fpx; px <= lpx; px++)
{
if(is_pixel(px, py))
{
/* Free mem */
delete cutrect;
delete scutrect;
/* Collision detected */
return true;
}
}
}
delete scutrect;
}
delete cutrect;
return false;
}