当前位置: 首页>>代码示例>>C++>>正文


C++ Hexagon::getBoundingBox方法代码示例

本文整理汇总了C++中Hexagon::getBoundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ Hexagon::getBoundingBox方法的具体用法?C++ Hexagon::getBoundingBox怎么用?C++ Hexagon::getBoundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hexagon的用法示例。


在下文中一共展示了Hexagon::getBoundingBox方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: collideBorderTiles

// Caution: Can possibly deactivate this territory and activate another.
void Territory::collideBorderTiles()
{
	for (int i = 0; i < borderCoordinates.size(); i++)
	{
		Hexagon * tile = floorTiles[borderCoordinates[i].q][borderCoordinates[i].r];

		if (Collision::hitBoxesOverlap(tile->getBoundingBox(), player->getBoundingBox(), player->getSpeed()))
		{
			std::list<Vector2f> penetration;

			if (SAT::collides(player->getConvexHull(), tile->getConvexHull(), player->getSpeed(), penetration))
			{
				// Move the player into another territory if the player is in a safe zone.
				if (player->getIsInSafeZone())
				{
					Vector2f direction = Vector2fMath::unitVector(player->getPosition() - position);
					Vector2f seekPosition = position + (direction * radius * 1.1f);

					world->changeTerritory(seekPosition);

					break;
				}
				else
				{
					player->translate(SAT::getShortestPenetration(penetration));
				}
			}
		}
	}
}
开发者ID:Kanel,项目名称:AllThemPixels,代码行数:31,代码来源:Territory.cpp

示例2: updatePlayer

// Updates the player and checks if the player is in a safe zone.
void Territory::updatePlayer(UpdateInfo info, Controls * controls)
{
	player->update(info, controls);
	player->setIsInSafeZone(false);

	// Check if the player is in a safe zone.
	for (int i = 0; i < 6 && !player->getIsInSafeZone(); i++)
	{
		for (int j = 0; j < safeZonesTiles[i].size(); j++)
		{
			Hexagon * tile = safeZonesTiles[i][j];

			if (Collision::hitBoxesOverlap(tile->getBoundingBox(), Vector2f(), player->getBoundingBox(), player->getSpeed()))
			{
				std::list<Vector2f> penetration;

				if (SAT::collides(player->getConvexHull(), tile->getConvexHull(), player->getSpeed(), penetration))
				{
					player->setIsInSafeZone(true);
					player->setSafeZoneIndex(i);

					break;
				}
			}
		}
	}
}
开发者ID:Kanel,项目名称:AllThemPixels,代码行数:28,代码来源:Territory.cpp


注:本文中的Hexagon::getBoundingBox方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。