Saxum/trigger.cc

25 lines
623 B
C++
Raw Normal View History

#include "trigger.hh"
2014-12-15 17:43:10 +00:00
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;
2014-12-15 17:43:10 +00:00
this->functionPointer = functionPointer;
}
Trigger::Trigger(){
}
Trigger::~Trigger(){
}
void Trigger::triggerUpdate(){
2014-12-15 17:43:10 +00:00
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
(*functionPointer)();
}
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
(*functionPointer)();
}
}