From b44df26d3ea5fcdaf6d954016303f358d2c64b79 Mon Sep 17 00:00:00 2001 From: aap Date: Tue, 5 May 2020 13:02:42 +0200 Subject: implemented most of streamed collisions and big buildings --- src/math/Rect.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/math') diff --git a/src/math/Rect.h b/src/math/Rect.h index fd1bd05e..326bb479 100644 --- a/src/math/Rect.h +++ b/src/math/Rect.h @@ -26,6 +26,25 @@ public: if(v.y < top) top = v.y; if(v.y > bottom) bottom = v.y; } + void ContainRect(const CRect &r){ + if(r.left < left) left = r.left; + if(r.right > right) right = r.right; + if(r.top < top) top = r.top; + if(r.bottom > bottom) bottom = r.bottom; + } + + bool IsPointInside(const CVector2D &p){ + return p.x >= left && + p.x <= right && + p.y >= top && + p.y <= bottom; + } + bool IsPointInside(const CVector2D &p, float extraRadius){ + return p.x >= left-extraRadius && + p.x <= right+extraRadius && + p.y >= top-extraRadius && + p.y <= bottom+extraRadius; + } void Translate(float x, float y){ left += x; -- cgit v1.2.3