本文整理汇总了C++中TileMap::findCollision方法的典型用法代码示例。如果您正苦于以下问题:C++ TileMap::findCollision方法的具体用法?C++ TileMap::findCollision怎么用?C++ TileMap::findCollision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileMap
的用法示例。
在下文中一共展示了TileMap::findCollision方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkProjectileCollision
Collision Projectile::checkProjectileCollision(TileMap &map)
{
if (!this->tileObject)
{
// It's possible the projectile reached the end of it's lifetime this frame
// so ignore stuff without a tile
return {};
}
sp<TileObject> ignoredObject = nullptr;
if (ownerInvulnerableTicks > 0)
{
if (firerVehicle)
{
ignoredObject = firerVehicle->tileObject;
}
else if (firerUnit)
{
ignoredObject = firerUnit->tileObject;
}
}
Collision c = map.findCollision(this->previousPosition, this->position, {}, ignoredObject);
if (!c)
return {};
c.projectile = shared_from_this();
return c;
}
示例2: test_collision
static void test_collision(const TileMap &map, Vec3<float> line_start, Vec3<float> line_end,
sp<TileObject> expected_collision)
{
auto collision = map.findCollision(line_start, line_end);
if (collision.obj != expected_collision)
{
LogError("Line between {%f,%f,%f} and {%f,%f,%f} collided with %s, expected %s",
line_start.x, line_start.y, line_start.z, line_end.x, line_end.y, line_end.z,
collision.obj ? collision.obj->getName() : "NONE",
expected_collision ? expected_collision->getName() : "NONE");
exit(EXIT_FAILURE);
}
}
示例3: checkProjectileCollision
Collision Projectile::checkProjectileCollision(TileMap &map)
{
if (!this->tileObject)
{
// It's possible the projectile reached the end of it's lifetime this frame
// so ignore stuff without a tile
return {};
}
Collision c = map.findCollision(this->previousPosition, this->position);
if (c && c.obj->getType() == TileObject::Type::Vehicle &&
this->firer == std::static_pointer_cast<TileObjectVehicle>(c.obj)->getVehicle())
{
return {};
}
c.projectile = shared_from_this();
return c;
}