本文整理汇总了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;
}