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


C++ AABB::GetWidth方法代码示例

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


在下文中一共展示了AABB::GetWidth方法的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;
}
开发者ID:kabinud,项目名称:HappyGame,代码行数:28,代码来源:DebugRenderer.cpp

示例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;
	}
}
开发者ID:Shane-S,项目名称:COMP8851-Assign3,代码行数:26,代码来源:AABB.cpp

示例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);
	}
}
开发者ID:LamePancake,项目名称:The-Mole,代码行数:63,代码来源:PlayerActor.cpp


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