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


C++ Wall::isColliding方法代码示例

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


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

示例1: checkForCollisions

BOOL Game::checkForCollisions()
{
	// NOTE: Things happen here in a specific order.  Collisions between non-wall objects
	// MUST MUST MUST happen before wall collisions.  The reason is that the player could
	// collide with a dragon and thus bounce off.  If this were to occur after wall collisions were
	// calculated, the player would more easily bounce through a wall.

    UINT i;
	SimpleArray *walls = itsPlayer->getRoom()->getWalls();
	GameObject *bridge = itsPlayer->getRoom()->searchRoom(GameObject::GAMEOBJECT_TYPE_BRIDGE);

	// TODO: clean this up
    SimpleArray *objects = itsWorld->getObjects();
    for (i=0;i<objects->length();i++)
    {
		GameObject *object = (GameObject *)(objects->elementAt(i));
		
		if (object->getType() == GameObject::GAMEOBJECT_TYPE_WALL)
			continue;

		for (UINT j=1;j<objects->length();j++)
		{
			GameObject *object2 = (GameObject *)(objects->elementAt(j));
			if (object2->getType() == GameObject::GAMEOBJECT_TYPE_WALL)
				continue;

			if (object->isColliding(object2))
			{
				object->collision(itsLastTickTime,object2);
				object2->collision(itsLastTickTime,object);
			}
		}
    }

	RECT playerRect;
	itsPlayer->getRect(&playerRect);

	BOOL onBridge = FALSE;
	for (i=0;i<walls->length();i++)
	{
	    Wall *thisWall = (Wall *)(walls->elementAt(i));
		if (thisWall->isColliding(itsPlayer))
		{
			// If the player's rect is colliding with the bridge, but not their actual pixels
			// (in other words, inside the bridge's rect, but not touching the bridge itself)
			if ( (bridge != NULL) && (ON_BRIDGE(bridge,itsPlayer,playerRect)) )
			{
				onBridge = TRUE;
			}
			else
			{
				itsPlayer->collision(itsLastTickTime,thisWall);
			}
		}
	}
	itsPlayer->setOnBridge(onBridge);

    return TRUE;
}
开发者ID:davetron5000,项目名称:adventureclone,代码行数:59,代码来源:Game.cpp


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