]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
E Triggers LEVER
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 21 Jun 2016 11:20:04 +0000 (13:20 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 21 Jun 2016 11:20:04 +0000 (13:20 +0200)
if hold, only once per second

Weave/Scene/Boar.cpp
Weave/Scene/EventBox.cpp
Weave/Scene/EventBox.h
Weave/Scene/Lever.cpp
Weave/Scene/Lever.h

index bc487854e33ea1ce4de2b7c445248221ff9d4e7f..bce2cb277adb0b1557f3e3a04929592082c32edb 100644 (file)
@@ -31,7 +31,7 @@ void Boar::update(float _deltaT)
 
 void Boar::collides(SceneObject * _other, btPersistentManifold * _contactManifold, float _deltaT)
 {
-       if (_other->collide_group != COL_MARVIN)
+       if (_other->collide_group != COL_MARVIN && _other->collide_group != COL_ENEMY)
                return;
 
        if (activated)
index 06b6a0dd3b3073ab4a2b78852e5c90b32ef0d191..f83369b3cd5a33341006ff333d423b47c7687699 100644 (file)
@@ -20,7 +20,7 @@ EventBox::EventBox(const mat4& _modelMat, eventBoxType _EB_TYPE) :
        eb_type(_EB_TYPE)
 {
        collide_group = COL_EVENT;
-       collide_with = COL_MARVIN;
+       collide_with = COL_MARVIN ;
 
        if (eb_type == EB_LEVER)
                collide_with = COL_LEVER;
@@ -52,13 +52,18 @@ EventBox::~EventBox()
 
 void EventBox::update(float _deltaT)
 {
+       SceneObject::update(_deltaT);
        if (activated)
        {
-               if (nextFrame)
+               triggertime += _deltaT;
+
+               if (triggertime >= 1.f)
+               {
                        activated = false;
-               else
-                       nextFrame = true;
-       }       
+               }
+                       
+       }
+               
 }
 
 void EventBox::draw(drawTarget _target) const
@@ -75,10 +80,7 @@ void EventBox::draw(drawTarget _target) const
 void EventBox::collides(SceneObject* _other, btPersistentManifold* _contactManifold, float _deltaT)
 {
        if (activated)
-       {
-                       nextFrame = false;
                        return;
-       }
 
        switch (eb_type)
        {
@@ -100,6 +102,7 @@ void EventBox::collides(SceneObject* _other, btPersistentManifold* _contactManif
                ((Lever*)_other)->trigger();
                break;
        }
-
+       
        activated = true;
+       triggertime = 0;
 }
index 814c8a646d3c09aeffb2513a4293073fd45ab7bb..78b3bd7181c651010a961c5a8cdaf3b53435afda 100644 (file)
@@ -25,5 +25,5 @@ protected:
        eventBoxType eb_type;
 
        bool activated = false;
-       bool nextFrame = true;
+       float triggertime = 0;
 };
index 8394384098c144f554c02c8867528f7ddf4b4c14..670545f9c92eb46b30ce90aabeb46c67bcdf341f 100644 (file)
@@ -1,5 +1,6 @@
 #include "Lever.h"
 #include "Scene.h"
+#include "../Message.h"
 
 Lever::Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath) : SceneObject(_modelMat, _material, _modelpath, texturepath)
 {
@@ -8,13 +9,6 @@ Lever::Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, st
        collide_with = COL_EVENT;
 }
 
-Lever::Lever(const mat4& modelMat, const vec4& material, Model* model, string texturepath) : SceneObject(modelMat, material, model, texturepath)
-{
-       recipient = nullptr;
-       collide_group = COL_LEVER;
-       collide_with = COL_EVENT;
-}
-
 Lever::~Lever()
 {
 
index 64fd442b46970725952154e862132c0e2ce9ec00..f852d6e588abeb69eb15bbd71435b39d55fdc11b 100644 (file)
@@ -10,7 +10,6 @@ class Lever : public SceneObject
 {
 public:
        Lever(const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath);
-       Lever(const mat4& modelMat, const vec4& material, Model* model, string texturepath);
        ~Lever();
        void setup(SceneObject* object);
        void trigger();