本文整理汇总了C++中AABB::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::GetHeight方法的具体用法?C++ AABB::GetHeight怎么用?C++ AABB::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::GetHeight方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CHR
RESULT
DebugRenderer::Quad( const AABB& bounds, Color color, float fOpacity )
{
RESULT rval = S_OK;
// Draw screen-aligned 2D rectangular outline for the AABB.
// TODO: have solid mode using a quad.
WORLD_POSITION corner1;
WORLD_POSITION corner2;
WORLD_POSITION corner3;
WORLD_POSITION corner4;
corner1.x = bounds.GetMin().x; corner1.y = bounds.GetMin().y; corner1.z = 0.0f;
corner2.x = bounds.GetMin().x; corner2.y = corner1.y + bounds.GetHeight(); corner2.z = 0.0f;
corner3.x = bounds.GetMax().x; corner3.y = bounds.GetMax().y; corner3.z = 0.0f;
corner4.x = bounds.GetMax().x; corner4.y = corner3.y - bounds.GetHeight(); corner4.z = 0.0f;
CHR( Line(corner1, vec3(0, 1, 0), Color::Green(), fOpacity, bounds.GetHeight(), 5.0f) );
CHR( Line(corner2, vec3(1, 0, 0), Color::Green(), fOpacity, bounds.GetWidth(), 5.0f) );
CHR( Line(corner3, vec3(0, -1, 0), Color::Green(), fOpacity, bounds.GetHeight(), 5.0f) );
CHR( Line(corner4, vec3(-1, 0, 0), Color::Green(), fOpacity, bounds.GetWidth(), 5.0f) );
// CHR( Point( bounds.GetCenter(), Color::Black(), 1.0f ) );
Exit:
return rval;
}
示例2: CheckCollision
bool AABB::CheckCollision(AABB otherBox)
{
//
// b0--------b1
// | |
// a0---|----a1 |
// | | | |
// | b3--------b2
// | |
// | |
// a3--------a2
//
// (a0.x is less than b1.x and a1.x is greater than b0.x) collided in x axis
// (a0.y is less than b3.y and a3.y is greater than b0.y) collided in y axis
//
if ((_x < otherBox.GetX() + otherBox.GetWidth() && _x + _width > otherBox.GetX()) &&
(_y < otherBox.GetY() + otherBox.GetHeight() && _y + _height > otherBox.GetY()))
{
// we collided
return true;
}
else
{
return false;
}
}
示例3: UpdateMindControlSelection
void PlayerActor::UpdateMindControlSelection(bool released)
{
shared_ptr<Level> level = _gameScreen->GetLevel();
vector<shared_ptr<AIActor>> inRange;
Vector2 centre{ _curKinematic.position.GetX() + _sprites[_currentSpriteSheet]->GetFrameWidth() / 2, _curKinematic.position.GetY() + _sprites[_currentSpriteSheet]->GetFrameHeight() / 2 };
for (auto actor : level->GetActors())
{
if (actor->GetType() == Type::enemy || actor->GetType() == Type::bombenemy)
{
// Check whether the enemy is in range, offsetting their position as necessary
// to make sure that the distance is the same on all sides
shared_ptr<AIActor> enemy = dynamic_pointer_cast<AIActor>(actor);
Vector2 enemyPos = enemy->GetPosition();
AABB enemyAABB = enemy->GetAABB();
if (enemyPos.GetX() < _curKinematic.position.GetX()) enemyPos.SetX(enemyPos.GetX() + enemyAABB.GetWidth());
if (enemyPos.GetY() < _curKinematic.position.GetY()) enemyPos.SetY(enemyPos.GetY() + enemyAABB.GetHeight());
if (centre.Distance(enemyPos) <= _mindControlRadius) inRange.push_back(enemy);
}
}
if (inRange.empty()) return;
if (released)
{
for (auto enemy : inRange)
{
enemy->SetIsMindControlCandidate(false);
enemy->SetSelectedForControl(false);
}
_selected = 0;
return;
}
for (auto enemy : inRange) enemy->SetIsMindControlCandidate(true);
inRange[_selected]->SetSelectedForControl(true);
// Cycle through the controllable enemies
if (_mgr->inputManager->ActionOccurred("MIND_CONTROL_SELECT", Input::Pressed))
{
inRange[_selected]->SetSelectedForControl(false);
_selected++;
_selected %= inRange.size();
inRange[_selected]->SetSelectedForControl(true);
}
// Toggle whether the enemy is under mind control
if (_mgr->inputManager->ActionOccurred("MIND_CONTROL_STOP", Input::Pressed))
{
inRange[_selected]->StopMindControl();
}
// Give the selected enemy a new direction in which to travel (and automatically enable mind control)
else if (_mgr->inputManager->ActionOccurred("LEFT", Input::Pressed) ||
_mgr->inputManager->ActionOccurred("RIGHT", Input::Pressed))
{
SpriteSheet::XAxisDirection dir = _mgr->inputManager->ActionOccurred("LEFT", Input::Pressed)
? SpriteSheet::XAxisDirection::LEFT
: SpriteSheet::XAxisDirection::RIGHT;
bool controlled = inRange[_selected]->IsUnderMindControl();
inRange[_selected]->SetMindControlDirection(dir);
}
}