summaryrefslogtreecommitdiff
path: root/gaunt01/src/trapdoor.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-03-31 16:44:02 +0100
committerTim Redfern <tim@eclectronics.org>2012-03-31 16:44:02 +0100
commit0e8f0361c1068eb4c2f634dfcf4e1762d87f40d2 (patch)
tree96a4eb154c1ac2dbe5ad4e04d4e33b281832e441 /gaunt01/src/trapdoor.cpp
parent623e1924aeea83ea70c8ae7f645b067f17a293ea (diff)
implementing trap door
Diffstat (limited to 'gaunt01/src/trapdoor.cpp')
-rw-r--r--gaunt01/src/trapdoor.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/gaunt01/src/trapdoor.cpp b/gaunt01/src/trapdoor.cpp
new file mode 100644
index 0000000..b53e30b
--- /dev/null
+++ b/gaunt01/src/trapdoor.cpp
@@ -0,0 +1,48 @@
+#include "trapdoor.h"
+
+trapdoor::trapdoor(ofRectangle _boundingRect,ofVec2f _doorSize)
+{
+ surround=morphmesh("trapdoor-surround.xml");
+ lid=morphmesh("trapdoor-lid.xml");
+ if (!surround.isLoaded()||!lid.isLoaded()) printf("problem loading trap door mesh.\n");
+
+ texture.loadImage("TextureTrapdoor.jpg");
+
+ boundingRect=_boundingRect;
+ doorSize=_doorSize;
+
+ start();
+}
+
+trapdoor::~trapdoor() {}
+
+void trapdoor::start(){
+ position=ofVec2f(boundingRect.x+ofRandom(boundingRect.width),boundingRect.y+ofRandom(boundingRect.height));
+ startTime=ofGetElapsedTimef();
+}
+
+void trapdoor::checkUpdate(const vector<ofVec3f>& players) {
+ if ((ofGetElapsedTimef()-startTime)>5) start();
+}
+
+void trapdoor::draw() {
+ bindTexture(texture);
+ ofPushMatrix();
+ ofTranslate(position.x,0,position.y);
+ //for now size =40x40
+ ofScale(.2,.2,.2);
+ surround.draw();
+ ofPushMatrix();
+ ofTranslate(-90,0,0);
+ ofRotate(doorAngle,1,0,0);
+ lid.draw();
+ ofPopMatrix();
+ ofPushMatrix();
+ ofTranslate(90,0,0);
+ ofRotate(180,0,1,0);
+ ofRotate(doorAngle,1,0,0);
+ lid.draw();
+ ofPopMatrix();
+ ofPopMatrix();
+ unbindTexture(texture);
+}