diff options
| -rw-r--r-- | gaunt01/src/main.cpp | 2 | ||||
| -rw-r--r-- | gaunt01/src/player.cpp | 2 | ||||
| -rw-r--r-- | gaunt01/src/testApp.cpp | 39 | ||||
| -rw-r--r-- | gaunt01/src/trapdoor.cpp | 8 |
4 files changed, 36 insertions, 15 deletions
diff --git a/gaunt01/src/main.cpp b/gaunt01/src/main.cpp index e502a4d..7f55863 100644 --- a/gaunt01/src/main.cpp +++ b/gaunt01/src/main.cpp @@ -6,7 +6,7 @@ int main( ){ ofAppGlutWindow window; - ofSetupOpenGL(&window, 640,480, OF_WINDOW); // <-------- setup the GL context + ofSetupOpenGL(&window, 1024,768, OF_FULLSCREEN); // <-------- setup the GL context // this kicks off the running of my app // can be OF_WINDOW or OF_FULLSCREEN diff --git a/gaunt01/src/player.cpp b/gaunt01/src/player.cpp index cd51097..efcdd0a 100644 --- a/gaunt01/src/player.cpp +++ b/gaunt01/src/player.cpp @@ -34,7 +34,7 @@ void player::update(ofxCvBlob blob) { tessellateToMesh(outline,OF_POLY_WINDING_NONZERO,billboard,true);
for (int i=0;i<billboard.getNumVertices();i++) {
ofVec3f v=billboard.getVertex(i);
- billboard.addTexCoord(ofVec2f(v.x,v.y));
+ billboard.addTexCoord(ofVec2f(v.x/ofGetWidth(),v.y/ofGetHeight()));
}
}
diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp index 58505b6..01afe95 100644 --- a/gaunt01/src/testApp.cpp +++ b/gaunt01/src/testApp.cpp @@ -69,7 +69,7 @@ void testApp::setup(){ bounds=new ofPlane[4]; - trapDoor=trapdoor(screen2plane(ofVec2f(ofGetWidth(),0)),screen2plane(ofVec2f(ofGetWidth(),ofGetHeight())),ofVec2f(30,30)); + trapDoor=trapdoor(screen2plane(ofVec2f(ofGetWidth(),0)),screen2plane(ofVec2f(ofGetWidth(),ofGetHeight())),ofVec2f(35,35)); updatePlane(); mode=PLAY; @@ -97,9 +97,9 @@ void testApp::setup(){ gameState=TITLES; - segTimes[TITLES]=5.0; - segTimes[CREDIT]=3.0; - segTimes[EXPLAIN]=6.0; + segTimes[TITLES]=4.0; + segTimes[CREDIT]=2.5; + segTimes[EXPLAIN]=5.0; segTimes[PLAYING]=60.0; segTimes[GOTCHA]=2.0; @@ -308,7 +308,13 @@ void testApp::update(){ else it->second.active=true; } } - if (trapDoor.checkUpdate(players)) updatePlane(); + if (trapDoor.checkUpdate(players)) { + if (gameState=PLAYING) { + gameState=GOTCHA; + gameStart=ofGetElapsedTimef(); + } + //updatePlane(); for new trapdoor + } Bird.update(players,cam_angle); } @@ -355,12 +361,12 @@ void testApp::draw(){ glDisable(GL_DEPTH_TEST); ofSetHexColor(0xffffff); - colorImg.getTextureReference().bind(); + bindTexture(colorImg); //colorImg.getTextureReference().bind(); map<int,player>::iterator it; for(int i=0;i<blobsManager.blobs.size();i++){ if(players[blobsManager.blobs.at(i).id].active) players[blobsManager.blobs.at(i).id].draw(); } - colorImg.getTextureReference().unbind(); + unbindTexture(colorImg); glEnable(GL_LIGHTING); @@ -381,36 +387,45 @@ void testApp::draw(){ if (gameTime>segTimes[gameState]) { gameState++; gameStart=ofGetElapsedTimef(); + gameTime=0.0f; } break; case PLAYING: if (gameTime>segTimes[gameState]) { gameState=TITLES; gameStart=ofGetElapsedTimef(); + gameTime=0.0f; + } + break; + case GOTCHA: + if (gameTime>segTimes[gameState]) { + gameState=PLAYING; + gameStart=ofGetElapsedTimef(); + gameTime=0.0f; } break; } - float segElapsed=gameTime/segTimes[gameState]; + float segElapsed=pow(gameTime/segTimes[gameState],2); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); switch(gameState) { case TITLES: billboards[0].draw(ofGetWidth()/6 - ,scaleFactor.y*((-billboards[0].height/2)+(billboards[0].height*sin(segElapsed*PI))) + ,scaleFactor.y*((-billboards[0].height/2)+(billboards[0].height*pow(sin(segElapsed*PI),0.5))) ,billboards[0].width*scaleFactor.x ,billboards[0].height*scaleFactor.y); break; case CREDIT: billboards[1].draw(ofGetWidth()/6 - ,ofGetHeight()+(scaleFactor.y*((billboards[1].height/2)-(billboards[1].height*sin(segElapsed*PI)))) + ,ofGetHeight()+(scaleFactor.y*((billboards[1].height/2)-(billboards[1].height*pow(sin(segElapsed*PI),0.5)))) ,billboards[1].width*scaleFactor.x ,billboards[1].height*scaleFactor.y); break; case EXPLAIN: billboards[2].draw(ofGetWidth()/2 - ,scaleFactor.y*((-billboards[2].height/2)+(billboards[2].height*sin(segElapsed*PI))) + ,scaleFactor.y*((-billboards[2].height/2)+(billboards[2].height*pow(sin(segElapsed*PI),0.5))) ,billboards[2].width*scaleFactor.x ,billboards[2].height*scaleFactor.y); break; @@ -418,7 +433,7 @@ void testApp::draw(){ break; case GOTCHA: billboards[3].draw(ofGetWidth()/2 - ,scaleFactor.y*((-billboards[2].height/2)+(billboards[3].height*sin(segElapsed*PI))) + ,scaleFactor.y*((-billboards[2].height/2)+(billboards[3].height*pow(sin(segElapsed*PI),0.5))) ,billboards[3].width*scaleFactor.x ,billboards[3].height*scaleFactor.y); break; diff --git a/gaunt01/src/trapdoor.cpp b/gaunt01/src/trapdoor.cpp index 5fc639f..6757a04 100644 --- a/gaunt01/src/trapdoor.cpp +++ b/gaunt01/src/trapdoor.cpp @@ -99,11 +99,13 @@ float trapdoor::getFalldist(){ bool trapdoor::checkUpdate(map<int,player>& players) { map<int,player>::iterator it; + bool gotcha=false; for (it=players.begin();it!=players.end();it++) { if (it->second.active) { ofVec3f p=it->second.getWorldPosition(); ofRectangle r=getInnerRect(); if (getInnerRect().inside(p.x,p.y)&&!it->second.isCaught) { + gotcha=true; trigger(); it->second.caught(); printf("caught!\n"); @@ -130,11 +132,15 @@ bool trapdoor::checkUpdate(map<int,player>& players) { opening=true; } } + /* if (segTime>13) { start(); return true; } else return false; + */ + + return gotcha; } void trapdoor::drawDebug() { @@ -160,7 +166,7 @@ void trapdoor::draw() { ofTranslate(ofVec3f(position.x,position.y,0)); ofPushMatrix(); ofRotate(90,-1,0,0); - ofScale(.15,.15,.15); + ofScale(.175,.175,.175); surround.draw(); ofPushMatrix(); ofTranslate(90,0,0); |
