From 0e8f0361c1068eb4c2f634dfcf4e1762d87f40d2 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 31 Mar 2012 16:44:02 +0100 Subject: implementing trap door --- gaunt01/src/trapdoor.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 gaunt01/src/trapdoor.cpp (limited to 'gaunt01/src/trapdoor.cpp') 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& 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); +} -- cgit v1.2.3