示例#1
0
void Player::handleDestructableCollisions(std::vector<Destructable*> destructables, Camera* camera)
{
	CollisionDetector detector;
	for(int i = 0; i < destructables.size(); ++i)
	{
		for(int j = 0; j < collisionPoints.size(); ++j)
		{
			CollisionPoint before = collisionPoints.at(j);
			CollisionPoint translatedPoint(before.x + movementVector.x, before.y + movementVector.y, before.type);
			if (detector.checkCollision(translatedPoint, destructables.at(i), camera))
			{
				switch (collisionPoints.at(j).type)
				{
					case HEAD: 
						movementVector.y = destructables.at(i)->getBoundingBox().y + destructables.at(i)->getBoundingBox().h + 1;
						break;
					case FEET:
						movementVector.y = destructables.at(i)->getBoundingBox().y - m_h;
						m_airbourne = false;
						break;
					case LEFT:
						movementVector.x = destructables.at(i)->getBoundingBox().x + destructables.at(i)->getBoundingBox().w + 1; // + camera->getOffsetX();
						break;
					case RIGHT:
						movementVector.x = destructables.at(i)->getBoundingBox().x - m_w - 1; // + camera->getOffsetX();
						break;
				}
			}
		}
	}
}
示例#2
0
 void UserInterface::TouchMotionEvent(Touch* movedTouch)
 {
     Vec2i translatedPoint(movedTouch->CurrentPoint.X * 2, movedTouch->CurrentPoint.Y * 2);
     int deltaX = _mousePosition.X - translatedPoint.X;
     int deltaY = _mousePosition.Y - translatedPoint.Y;
     _mousePosition.X = translatedPoint.X;
     _mousePosition.Y = translatedPoint.Y;
     AngelCanvas->InputMouseMoved(translatedPoint.X, translatedPoint.Y, deltaX, deltaY);
 }