-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgameobject.cpp
More file actions
62 lines (50 loc) · 981 Bytes
/
gameobject.cpp
File metadata and controls
62 lines (50 loc) · 981 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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "gameobject.h"
#include <cmath>
GameObject::GameObject(double x, double y, double a)
: x(x), y(y), angle(a)
{
}
double GameObject::getX()
{
return x;
}
void GameObject::setX(double x)
{
this->x = x;
}
double GameObject::getY()
{
return y;
}
void GameObject::setY(double y)
{
this->y = y;
}
double GameObject::getRadius()
{
return radius;
}
double GameObject::getAngle()
{
return angle;
}
void GameObject::setAngle(double angle)
{
this->angle = angle;
}
double GameObject::getAngleTo(double x, double y)
{
return atan2(x - this->x, y - this->y);
}
double GameObject::getAngleTo(GameObject &obj)
{
return getAngleTo(obj.x, obj.y);
}
double GameObject::getDistanceTo(double x, double y)
{
return sqrt((x - this->x)*(x - this->x) + (y - this->y)*(y - this->y));
}
double GameObject::getDistanceTo(GameObject &obj)
{
return getDistanceTo(obj.x, obj.y);
}