summaryrefslogtreecommitdiff
path: root/gaunt01/src/testApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-04-19 14:49:22 +0100
committerTim Redfern <tim@eclectronics.org>2012-04-19 14:49:22 +0100
commit1a10f22b131e9d16bcfadebcee25690fda31c9fc (patch)
treef10a801c40454f68e31f9df7108cc3384755e505 /gaunt01/src/testApp.cpp
parente64e431b123da3afd0658375f91f50ed00910f67 (diff)
better billboards
Diffstat (limited to 'gaunt01/src/testApp.cpp')
-rw-r--r--gaunt01/src/testApp.cpp39
1 files changed, 27 insertions, 12 deletions
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;