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


C++ CBaseEntity::GetSolidType方法代码示例

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


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

示例1: IsSpaceEmpty

bool IsSpaceEmpty( CBaseEntity *pEntity )
{
	bool bEmpty = true;

	Vector vecMins, vecMaxs;
	pEntity->GetAbsBounds( &vecMins, &vecMaxs );

	// World bounds!
	if ( !g_ScreenRect.contains( vecMins ) || !g_ScreenRect.contains( vecMaxs ) )
	{
		// Screen edges are always solid.
		bEmpty = false;
	}

	for ( int i = 0; i < MAX_ENTITIES; i++ )
	{
		CBaseEntity *pOther = g_EntityList[i];
		if ( !pOther || pOther == pEntity || pOther->GetSolidType() == SOLID_NO )
			continue;

		Vector vecOtherMins, vecOtherMaxs;
		pOther->GetAbsBounds( &vecOtherMins, &vecOtherMaxs );

		if ( IsBoxIntersectingBox( vecMins, vecMaxs, vecOtherMins, vecOtherMaxs ) )
		{
			if ( pOther->IsSolid() )
			{
				bEmpty = false;
			}
		}
	}

	return bEmpty;
}
开发者ID:NicknineTheEagle,项目名称:Breakout,代码行数:34,代码来源:baseentity.cpp

示例2: ProcessMovement

//-----------------------------------------------------------------------------
// Purpose: "Physics" simulation.
//-----------------------------------------------------------------------------
void CBaseEntity::ProcessMovement( void )
{
	// Test new position.
	Vector vecNewOrigin = m_vecOrigin + m_vecVelocity * g_FrameTime;
	Vector vecMins = vecNewOrigin + m_vecMins;
	Vector vecMaxs = vecNewOrigin + m_vecMaxs;

	// Test collision against other entities.
	// Since movement amount depends on frame time and we only test the final position
	// this whole system goes out of the window at low framerates.
	bool bCanMove = true;

	if ( GetSolidType() != SOLID_NO )
	{
		// World bounds!
		if ( !g_ScreenRect.contains( vecMins ) || !g_ScreenRect.contains( vecMaxs ) )
		{
			TouchScreenEdge( vecNewOrigin );

			// Screen edges are always solid.
			if ( IsSolid() )
			{
				bCanMove = false;
			}
		}

		for ( int i = 0; i < MAX_ENTITIES; i++ )
		{
			CBaseEntity *pEntity = g_EntityList[i];
			if ( !pEntity || pEntity == this || pEntity->GetSolidType() == SOLID_NO )
				continue;

			Vector vecOtherMins, vecOtherMaxs;
			pEntity->GetAbsBounds( &vecOtherMins, &vecOtherMaxs );

			if ( IsBoxIntersectingBox( vecMins, vecMaxs, vecOtherMins, vecOtherMaxs ) )
			{
				OnCollide( pEntity );

				if ( IsSolid() && pEntity->IsSolid() )
				{
					bCanMove = false;
				}
			}
		}
	}

	if ( bCanMove )
		m_vecOrigin = vecNewOrigin;

	// Move the sprite if we have one.
	if ( m_pSprite )
	{
		m_pSprite->setPosition( m_vecOrigin );
		m_pSprite->setRotation( m_flAngle );
	}
}
开发者ID:NicknineTheEagle,项目名称:Breakout,代码行数:60,代码来源:baseentity.cpp


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