moveByVector method

bool moveByVector(
  1. Vector2 speed
)

Implementation

bool moveByVector(Vector2 speed) {
  double innerSpeedX = speed.x * dtUpdate;
  double innerSpeedY = speed.y * dtUpdate;
  Vector2 displacement = position.translate(innerSpeedX, innerSpeedY);

  if (_isCollision(displacement)) {
    return false;
  }

  isIdle = false;
  position = displacement;
  return true;
}