本文整理汇总了C++中Vector2::Get_Y方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::Get_Y方法的具体用法?C++ Vector2::Get_Y怎么用?C++ Vector2::Get_Y使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::Get_Y方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsColliding
bool CollisionVolume::IsColliding(Collider* other) const
{
Vector2 max = *m_bounds->GetMax();
Vector2 min = *m_bounds->GetMin();
Vector2 max_other = *(other->GetBounds()->GetMax());
Vector2 min_other = *(other->GetBounds()->GetMin());
//if any of these are true, then the objects are not colliding
if (max.Get_X() > max_other.Get_X() || min.Get_X() < min_other.Get_X() ||
max.Get_Y() > max_other.Get_Y() || min.Get_Y() < min_other.Get_Y() )
{
return false;
}
return false;
}
示例2: HandleCollision
void CollisionVolume::HandleCollision(Collider* other)
{
Vector2 max = *m_bounds->GetMax();
Vector2 min = *m_bounds->GetMin();
Vector2 max_other = *(other->GetBounds()->GetMax());
Vector2 min_other = *(other->GetBounds()->GetMin());
float halfSize = other->GetBounds()->GetSize() / 2;
Vector2* otherPos = other->GetPosition();
if (max_other.Get_X() > max.Get_X())
{
//force left
otherPos->Set_X(max.Get_X() - halfSize);
}
if (min_other.Get_X() < min.Get_X())
{
//force right
otherPos->Set_X(min.Get_X() + halfSize);
}
if (max_other.Get_Y() > max.Get_Y())
{
//force down
otherPos->Set_Y(max.Get_Y() - halfSize);
}
if (min_other.Get_Y() < min.Get_Y())
{
//force up
otherPos->Set_Y(min.Get_Y() + halfSize);
}
other->GetBounds()->UpdateBounds(otherPos);
other->GetGameOjbect()->SetPosition(otherPos);
}