-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.cpp
78 lines (71 loc) · 1.23 KB
/
Object.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "Object.h"
// constructor
Object::Object() {
position[0] = 0.0f, position[1] = 0.0f;
velocity[0] = 0.0f, velocity[1] = 0.0f;
}
// position methods
void Object::setPosition(float x, float y)
{
position[0] = x; position[1] = y;
}
float* Object::getPosition()
{
return position;
}
void Object::setPositionX(float x)
{
position[0] = x;
}
float Object::getPositionX()
{
return position[0];
}
void Object::setPositionY(float y)
{
position[1] = y;
}
float Object::getPositionY()
{
return position[1];
}
// velocity methods
void Object::setVelocity(float v1, float v2)
{
velocity[0] = v1; velocity[1] = v2;
}
float* Object::getVelocity()
{
return velocity;
}
void Object::setVelocityX(float v1)
{
velocity[0] = v1;
}
float Object::getVelocityX()
{
return velocity[0];
}
void Object::setVelocityY(float v2)
{
velocity[1] = v2;
}
float Object::getVelocityY()
{
return velocity[1];
}
Hitbox Object::getHitbox()
{
Hitbox hitbox = Hitbox(0.0f, 0.0f, 0.0f, 0.0f);
return hitbox;
}
void Object::translate(float x, float y)
{
setPosition(getPositionX() + x, getPositionY() + y);
}
bool Object::collisionDetection(Object& other)
{
Hitbox hitbox1 = getHitbox();
Hitbox hitbox2 = other.getHitbox();
return hitbox1.collisionDetection(hitbox2);
}