diff options
| author | Tim Redfern <tim@eclectronics.org> | 2012-03-31 22:17:55 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2012-03-31 22:17:55 +0100 |
| commit | 81508e0a24b9981f08afe3752093ed626a2c51d9 (patch) | |
| tree | 56004bbe953adcda555149aaa255c6b3b4cbd111 /gaunt01/src/trapdoor.cpp | |
| parent | 0e8f0361c1068eb4c2f634dfcf4e1762d87f40d2 (diff) | |
nearly working trap door
Diffstat (limited to 'gaunt01/src/trapdoor.cpp')
| -rw-r--r-- | gaunt01/src/trapdoor.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gaunt01/src/trapdoor.cpp b/gaunt01/src/trapdoor.cpp index b53e30b..607c40f 100644 --- a/gaunt01/src/trapdoor.cpp +++ b/gaunt01/src/trapdoor.cpp @@ -10,6 +10,9 @@ trapdoor::trapdoor(ofRectangle _boundingRect,ofVec2f _doorSize) boundingRect=_boundingRect; doorSize=_doorSize; + + doorAngle=0; + doorSpeed=0; start(); } @@ -19,30 +22,37 @@ trapdoor::~trapdoor() {} void trapdoor::start(){ position=ofVec2f(boundingRect.x+ofRandom(boundingRect.width),boundingRect.y+ofRandom(boundingRect.height)); startTime=ofGetElapsedTimef(); + doorAngle=0; } void trapdoor::checkUpdate(const vector<ofVec3f>& players) { - if ((ofGetElapsedTimef()-startTime)>5) start(); + float segTime=(ofGetElapsedTimef()-startTime); + if (segTime>5) start(); + if (segTime>4) doorAngle-=(cos(doorAngle*0.0174532925)/ofGetFrameRate())*200; } void trapdoor::draw() { + glEnable(GL_DEPTH_TEST); bindTexture(texture); ofPushMatrix(); + ofRotate(90,-1,0,0); ofTranslate(position.x,0,position.y); + ofRotate(180,-1,0,0); //for now size =40x40 - ofScale(.2,.2,.2); + ofScale(.1,.1,.1); surround.draw(); ofPushMatrix(); - ofTranslate(-90,0,0); - ofRotate(doorAngle,1,0,0); + ofTranslate(90,0,0); + ofRotate(doorAngle,0,0,1); lid.draw(); ofPopMatrix(); ofPushMatrix(); - ofTranslate(90,0,0); + ofTranslate(-90,0,0); ofRotate(180,0,1,0); - ofRotate(doorAngle,1,0,0); + ofRotate(doorAngle,0,0,1); lid.draw(); ofPopMatrix(); ofPopMatrix(); unbindTexture(texture); + glDisable(GL_DEPTH_TEST); } |
