本文整理汇总了C++中Physics::Vector方法的典型用法代码示例。如果您正苦于以下问题:C++ Physics::Vector方法的具体用法?C++ Physics::Vector怎么用?C++ Physics::Vector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics::Vector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
// Ensure the boxes are in the correct place
void Window::update()
{
// The window box should only shift if the deadzone is not in the center
if (deadzone.a.x - box.a.x < WINDOW_WIDTH / 3) box += Vector(-(WINDOW_WIDTH / 3 - (deadzone.a.x - box.a.x)), 0);
else if (box.b.x - deadzone.b.x < WINDOW_WIDTH / 3) box += Vector((WINDOW_WIDTH / 3 - (box.a.x - deadzone.a.x)), 0);
if (deadzone.a.y - box.a.y < WINDOW_HEIGHT / 3) box += Vector(0, -(WINDOW_HEIGHT / 3 - (deadzone.a.y - box.a.y)));
else if (box.b.y - deadzone.b.y < WINDOW_HEIGHT / 3) box += Vector(0, (WINDOW_HEIGHT / 3 - (box.a.y - deadzone.a.y)));
// Don't let the window box go outside the world
if (box.a.x < 0) box += Vector(-box.a.x, 0);
else if (box.b.x > WORLD_WIDTH * BLOCK_SIZE) box += Vector(WORLD_WIDTH * BLOCK_SIZE - box.b.x, 0);
if (box.a.y < 0) box += Vector(0, -box.a.y);
else if (box.b.y > WORLD_HEIGHT * BLOCK_SIZE) box += Vector(0, WORLD_HEIGHT * BLOCK_SIZE - box.b.y);
}