From 1a10f22b131e9d16bcfadebcee25690fda31c9fc Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 19 Apr 2012 14:49:22 +0100 Subject: better billboards --- gaunt01/src/main.cpp | 2 +- gaunt01/src/player.cpp | 2 +- gaunt01/src/testApp.cpp | 39 +++++++++++++++++++++++++++------------ gaunt01/src/trapdoor.cpp | 8 +++++++- 4 files changed, 36 insertions(+), 15 deletions(-) (limited to 'gaunt01/src') 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;isecond.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::iterator it; for(int i=0;isegTimes[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& players) { map::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& 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); -- cgit v1.2.3