summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-03-31 22:17:55 +0100
committerTim Redfern <tim@eclectronics.org>2012-03-31 22:17:55 +0100
commit81508e0a24b9981f08afe3752093ed626a2c51d9 (patch)
tree56004bbe953adcda555149aaa255c6b3b4cbd111
parent0e8f0361c1068eb4c2f634dfcf4e1762d87f40d2 (diff)
nearly working trap door
-rw-r--r--gaunt01/gaunt01.layout20
-rw-r--r--gaunt01/src/testApp.cpp6
-rw-r--r--gaunt01/src/trapdoor.cpp22
-rw-r--r--gaunt01/src/trapdoor.h1
4 files changed, 34 insertions, 15 deletions
diff --git a/gaunt01/gaunt01.layout b/gaunt01/gaunt01.layout
index e5fb8e8..c2ecf4b 100644
--- a/gaunt01/gaunt01.layout
+++ b/gaunt01/gaunt01.layout
@@ -1,16 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
- <File name="addons.make" open="0" top="0" tabpos="0">
- <Cursor position="16" topLine="0" />
+ <File name="addons.make" open="1" top="0" tabpos="2">
+ <Cursor position="31" topLine="0" />
</File>
- <File name="config.make" open="1" top="0" tabpos="3">
+ <File name="config.make" open="0" top="0" tabpos="3">
<Cursor position="192" topLine="0" />
</File>
- <File name="src/testApp.cpp" open="1" top="1" tabpos="1">
- <Cursor position="1491" topLine="16" />
+ <File name="src/testApp.cpp" open="0" top="0" tabpos="1">
+ <Cursor position="4771" topLine="162" />
</File>
- <File name="src/testApp.h" open="1" top="0" tabpos="2">
- <Cursor position="58" topLine="0" />
+ <File name="src/testApp.h" open="1" top="1" tabpos="1">
+ <Cursor position="1151" topLine="28" />
+ </File>
+ <File name="src/trapdoor.cpp" open="0" top="0" tabpos="0">
+ <Cursor position="1102" topLine="0" />
+ </File>
+ <File name="src/trapdoor.h" open="1" top="0" tabpos="3">
+ <Cursor position="258" topLine="0" />
</File>
</CodeBlocks_layout_file>
diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp
index 1ab413b..3b81cdd 100644
--- a/gaunt01/src/testApp.cpp
+++ b/gaunt01/src/testApp.cpp
@@ -39,7 +39,9 @@ void testApp::setup(){
cam.lookAt(ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0),ofVec3f(0, -1, 0));
cam.setFov(42.0); //39.85); //53.13);
- trapDoor=trapdoor(ofRectangle(0,0,ofGetWidth(),ofGetHeight()),ofVec2f(20,20));
+ trapDoor=trapdoor(ofRectangle(0,ofGetHeight()/4,ofGetHeight(),ofGetHeight()),ofVec2f(20,20));
+
+
}
@@ -114,6 +116,7 @@ void testApp::draw(){
ofPushMatrix();
ofRotate(cam_angle,1,0,0);
+ //cam.Rotate(cam_angle,1,0,0);
for (float i=0;i<=ofGetWidth();i+=ofGetWidth()/10) {
glBegin(GL_LINES);
@@ -175,7 +178,6 @@ void testApp::draw(){
ofBox(0,-10,0,20);
//for now, draw in this axis
ofPopMatrix();
-
}
trapDoor.checkUpdate(players);
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);
}
diff --git a/gaunt01/src/trapdoor.h b/gaunt01/src/trapdoor.h
index 16ad3b1..43121e3 100644
--- a/gaunt01/src/trapdoor.h
+++ b/gaunt01/src/trapdoor.h
@@ -38,6 +38,7 @@ class trapdoor
ofVec2f doorSize;
float doorAngle;
+ float doorSpeed;
ofImage texture;