Saxum/trigger.cc
2014-12-15 18:43:10 +01:00

25 lines
623 B
C++

#include "trigger.hh"
Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, void (*functionPointer)()) {
this->position=position;
this->distance=distance;
this->isBigger=isBigger;
this->object=object;
this->functionPointer = functionPointer;
}
Trigger::Trigger(){
}
Trigger::~Trigger(){
}
void Trigger::triggerUpdate(){
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
(*functionPointer)();
}
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
(*functionPointer)();
}
}