-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2.cpp
More file actions
49 lines (39 loc) · 759 Bytes
/
Vector2.cpp
File metadata and controls
49 lines (39 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "Vector2.h"
Vector2::Vector2()
{
x = 0.0f;
y = 0.0f;
}
Vector2::Vector2(float x_, float y_)
{
x = x_;
y = y_;
}
Vector2::~Vector2()
{
}
int Vector2::getDistanceTo(Vector2 vector2)
{
return (int)(sqrt( pow( vector2.x - x, 2) + pow( vector2.y - y, 2)));
}
Rect::Rect()
{
mPosition = Vector2(0.0f, 0.0f);
mSize = Vector2(0.0f, 0.0f);
}
Rect::Rect(Vector2 pos, Vector2 size)
{
mPosition = pos;
mSize = size;
}
Rect::~Rect()
{
}
bool Rect::checkCollision(Rect otherRect)
{
if (mPosition.x + mSize.x >= otherRect.mPosition.x && mPosition.x <= otherRect.mPosition.x + otherRect.mSize.x
&& mPosition.y + mSize.y >= otherRect.mPosition.y && mPosition.y <= otherRect.mPosition.y + otherRect.mSize.y)
return true;
else
return false;
}