diff options
Diffstat (limited to 'gaunt01/src/trapdoor.cpp')
| -rw-r--r-- | gaunt01/src/trapdoor.cpp | 48 |
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); +} |
