本文整理汇总了C++中MapLine::y1方法的典型用法代码示例。如果您正苦于以下问题:C++ MapLine::y1方法的具体用法?C++ MapLine::y1怎么用?C++ MapLine::y1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapLine
的用法示例。
在下文中一共展示了MapLine::y1方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doCheck
void doCheck()
{
double radius;
// Get list of lines to check
vector<MapLine*> check_lines;
MapLine* line;
for (unsigned a = 0; a < map->nLines(); a++)
{
line = map->getLine(a);
// Skip if line is 2-sided and not blocking
if (line->s2() && !theGameConfiguration->lineBasicFlagSet("blocking", line, map->currentFormat()))
continue;
check_lines.push_back(line);
}
// Go through things
for (unsigned a = 0; a < map->nThings(); a++)
{
MapThing* thing = map->getThing(a);
ThingType* tt = theGameConfiguration->thingType(thing->getType());
// Skip if not a solid thing
if (!tt->isSolid())
continue;
radius = tt->getRadius() - 1;
// Go through lines
for (unsigned b = 0; b < check_lines.size(); b++)
{
line = check_lines[b];
// Check intersection
if (MathStuff::boxLineIntersect(thing->xPos() - radius, thing->yPos() - radius,
thing->xPos() + radius, thing->yPos() + radius,
line->x1(), line->y1(), line->x2(), line->y2()))
{
things.push_back(thing);
lines.push_back(line);
break;
}
}
}
}
示例2: fixProblem
bool fixProblem(unsigned index, unsigned fix_type, MapEditor* editor)
{
if (index >= things.size())
return false;
if (fix_type == 0)
{
MapThing* thing = things[index];
MapLine* line = lines[index];
// Get nearest line point to thing
fpoint2_t np = MathStuff::closestPointOnLine(thing->xPos(), thing->yPos(), line->x1(), line->y1(), line->x2(), line->y2());
// Get distance to move
double r = theGameConfiguration->thingType(thing->getType())->getRadius();
double dist = MathStuff::distance(0, 0, r, r);
editor->beginUndoRecord("Move Thing", true, false, false);
// Move along line direction
map->moveThing(thing->getIndex(), np.x - (line->frontVector().x * dist), np.y - (line->frontVector().y * dist));
editor->endUndoRecord();
return true;
}
return false;
}