-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollider.cpp
More file actions
29 lines (25 loc) · 737 Bytes
/
Collider.cpp
File metadata and controls
29 lines (25 loc) · 737 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
#include <iostream>
#include "Collider.hpp"
#include "GameObject.hpp"
Collider::Collider( GameObject * aParent, float aRadius )
: parent(aParent), radius( aRadius )
{
//ctor
}
Collider::~Collider()
{
//dtor
}
bool Collider::collides( Collider * otherCollider )
{
//std::cout << "Check CD for " << parent->getName() << std::endl;
glm::vec3 location = parent->getLocation();
glm::vec3 otherLocation = otherCollider->parent->getLocation();
float distance = glm::distance( location, otherLocation );
if ( distance < radius + otherCollider->radius ) {
//std::cout << parent->getName() << " Hits " << otherCollider->parent->getName() << std::endl;
parent->onCollision(otherCollider->parent);
return true;
};
return false;
}