-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGameObject.cpp
More file actions
77 lines (61 loc) · 1.56 KB
/
GameObject.cpp
File metadata and controls
77 lines (61 loc) · 1.56 KB
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
//Main header
#include <GameObject.h>
//Headers
#include <Physics.h>
#include <Render.h>
/*=================================================*/
/*================== Metodos ==================*/
/*=================================================*/
bool drawBB = false;
GameObject::GameObject()
{
physics = new Physics();
}
GameObject::~GameObject()
{
delete physics;
Render::getInstance()->deleteAnimation(animation);
}
Physics* GameObject::getPhysics()
{
return physics;
}
void GameObject::setAnimation(unsigned int animation)
{
this->animation = animation;
}
bool GameObject::checkColision(GameObject* object)
{
if(!object)
return false;
return physics->colides(object->getPhysics());
}
void GameObject::update(float dt)
{
physics->update(dt);
}
void GameObject::draw()
{
Render::getInstance()->drawAnimation(animation, Rvect(physics->getPosition().x, physics->getPosition().y),physics->getOrient());
if(drawBB)
{
switch (physics->getBBType())
{
case NOCOLIDER:
/* code */
break;
case CIRCLE:
Render::getInstance()->drawCircle(Rvect(physics->getPosition().x, physics->getPosition().y),physics->getRadious());
break;
case RECTANGLE:
Render::getInstance()->drawRectangle(Rvect(physics->getPosition().x, physics->getPosition().y), Rvect(physics->getDimensions().x, physics->getDimensions().y));
break;
default:
break;
}
}
}
void GameObject::setDrawBB()
{
drawBB = !drawBB;
}