本文整理汇总了PHP中Math::pointSum方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::pointSum方法的具体用法?PHP Math::pointSum怎么用?PHP Math::pointSum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::pointSum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isHit
/**
* @param CannonBall $object
* @return bool
*/
public function isHit($object)
{
if ($object instanceof CannonBall) {
foreach ($object->pixels as $pixel) {
if (!$pixel->destroyedLocation) {
$currentPosition = Math::pointSum($object->position, $pixel);
$previousPosition = Math::pointSum($object->previousPosition, $pixel);
if (!$this->triggered && ($currentPosition->x >= $this->position->x && $previousPosition->x <= $this->position->x)) {
$diff = Math::pointDiff($currentPosition, $previousPosition);
$slope = 0;
if ($diff->x != 0) {
$slope = -1 * ($diff->y / $diff->x);
}
$intercept = $this->position->y - $previousPosition->y;
$intersectPoint = new Point($this->position->x, $this->position->y + ($slope * ($this->position->x - $previousPosition->x) - $intercept));
if ($intersectPoint->y >= $this->position->y && $intersectPoint->y <= $this->position->y + 13) {
$this->triggered = true;
$this->powerCordColor = Color::WHITE;
return $this->triggered;
}
}
}
}
}
return false;
}