#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& 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); }