Exemplo n.º 1
0
	void SelectionImage::Update()
	{
		Entity::Update();

		Vector2 diff = Input::GetWorldMousePosition() - GetWorldPosition();//position - Graphics::GetScreenCenter();
		float mag = (1.0f-(diff.GetMagnitude()/256.0f)) * 1.0f;
		if (mag < 0.5f) mag = 0.5f;
		if (mag > 1.25f) mag = 1.25f;
		scale = Vector2::one * mag;
		printf("scale %f, %f\n", scale.x, scale.y);
	}
Exemplo n.º 2
0
	bool Collider::CollideCircleCircle(CircleCollider* a, CircleCollider* b, CollisionData *collisionData)
	{
		Vector2 diff = a->GetCenter() - b->GetCenter();
		if (diff.IsInRange(a->GetRadius() + b->GetRadius()))
		{
			if (collisionData)
			{
				collisionData->normal = diff.GetNormalized();
				collisionData->penetration = (a->GetRadius() + b->GetRadius()) - diff.GetMagnitude();
				collisionData->hitPoint = diff * 0.5f + b->GetCenter();
			}
			return true;
		}
		return false;
	}
Exemplo n.º 3
0
double Vector2::ScalarProjection(const Vector2& onto) const
{
    return this->Dot(onto) / onto.GetMagnitude();
}