From 19c84c74efd5b8ffd1fb8184037910c831990d2e Mon Sep 17 00:00:00 2001 From: Comment Date: Wed, 12 Dec 2012 10:57:40 +0000 Subject: version for galway gig --- vfg/src/testApp.cpp | 69 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'vfg/src/testApp.cpp') diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index 4e5e576..2a95571 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -198,9 +198,10 @@ void testApp::update(){ activatePractice(); } else if (ret==ASTERISK_GAMEOVER) { - printf("player hung up!\n"); - songs[currentsong]->gameOver(); - endGame(); + if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE||gamestate==GAME_PRACTICE2) { + printf("player hung up!\n"); + endGame(); + } } else if (ret>48&&ret<52) { songs[currentsong]->playerControl(ret-49); @@ -212,6 +213,11 @@ void testApp::update(){ practiceSong.playerControl(ret-52); (*playanimal)[ret-52].playNow("Clap"); } + else if (ret>54&&ret<58) { + songs[currentsong]->playerControl(ret-55); + practiceSong.playerControl(ret-55); + (*playanimal)[ret-55].playNow("Clap"); + } if (songs[currentsong]->isPlaying&&songs[currentsong]->getLevel(ofGetElapsedTimeMillis()+4000)>currentlevel) { int anim=ofRandom(1.9999); //this gives a binary random number for (int i=0;i<3;i++) { @@ -230,13 +236,13 @@ void testApp::update(){ case GAME_ENDPLAYING: case GAME_ENDINGINTRO: case GAME_PRACTICE: + case GAME_PRACTICE2: case GAME_WALKON: background.update(); banner.update(); wirebirds.update(); break; case GAME_STARTINGINTRO: - background.update(); case GAME_INTRO: intro.update(); break; @@ -247,6 +253,9 @@ void testApp::update(){ case GAME_ADVERT: advert.update(); break; + case GAME_ENDTITLE: + background.update(); + break; } } @@ -299,6 +308,7 @@ void testApp::draw(){ switch(gamestate) { case GAME_STARTINGINTRO: case GAME_INTRO: + ofDisableAlphaBlending(); intro.draw(hOffs,0,ofGetHeight(),ofGetHeight()); break; case GAME_ENDINGINTRO: @@ -310,6 +320,7 @@ void testApp::draw(){ case GAME_ENDPLAYING: case GAME_WALKON: case GAME_ENDTITLE: + ofDisableAlphaBlending(); drawBackgroundLayers(); break; case GAME_STARTINGADVERT: @@ -347,8 +358,10 @@ void testApp::draw(){ } } aspect=advert.getHeight()/advert.getWidth(); - wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5; - advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect); + float maxwidth=min((float)ofGetWidth(),ofGetHeight()*1.2f); + float wstart=(ofGetWidth()-maxwidth)*0.5; + wOffs=(ofGetHeight()-(maxwidth*aspect))*0.5; + advert.draw(wstart,wOffs,maxwidth,maxwidth*aspect); ofDisableAlphaBlending(); //may have been turned on during intro break; @@ -443,8 +456,8 @@ void testApp::draw(){ } else break; case GAME_ENDTITLE: - //DCC LOGO - logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); + //DCC LOGO FOR DUBLIN + //logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); case GAME_ENDINGINTRO: case GAME_READY: case GAME_STARTPLAYING: @@ -465,11 +478,13 @@ void testApp::draw(){ //draw banner and wirebirds bannerscale=scale; ofSetColor(255,255,255); + float birdoffset; switch(gamestate) { case GAME_PRACTICE: ofEnableAlphaBlending(); bannerscale=scale*(1.0f-(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.002,1.0))*0.325)); - wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale); + birdoffset=-((1.0f-(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.0003,1.0))))*ofGetWidth()); + wirebirds.draw(birdoffset+(ofGetWidth()/2),ofGetHeight()*birdpoint,scale); segamt=1.0; ofEnableAlphaBlending(); banner.draw(ofGetWidth()*0.5,0,bannerscale); @@ -494,19 +509,17 @@ void testApp::draw(){ case GAME_PRACTICE2: case GAME_STARTPLAYING: case GAME_PLAYING: - if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale); - bannerscale=scale*0.675; - ofEnableAlphaBlending(); - banner.draw(ofGetWidth()*0.5,0,bannerscale); - break; case GAME_ENDPLAYING: - bannerscale=scale*0.675; ofEnableAlphaBlending(); + if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale); + bannerscale=scale*0.675; banner.draw(ofGetWidth()*0.5,0,bannerscale); break; case GAME_WALKON: - bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); ofEnableAlphaBlending(); + bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); + birdoffset=(((max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.0003,1.0))))*ofGetWidth()); + if (showWire) wirebirds.draw(birdoffset+(ofGetWidth()/2),ofGetHeight()*birdpoint,scale); banner.draw(ofGetWidth()*0.5,0,bannerscale); break; } @@ -565,6 +578,7 @@ void testApp::draw(){ case GAME_PLAYING: backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0))); if (songs[currentsong]->isGameover()) { + hangUp(); endGame(); } break; @@ -660,11 +674,11 @@ void testApp::queueWalkOn(){ (*playanimal)[i].clear(); int numcycles,start; if (playanimal==&penguins) { - start=400; //(of 700 cycle) + start=600; //(of 700 cycle) was 400 numcycles=7; } else { - start=400; //of 780 + start=200; //of 780 was 400 numcycles=5; } (*playanimal)[i].play("Walking",ofGetElapsedTimeMillis()+start); @@ -672,15 +686,25 @@ void testApp::queueWalkOn(){ (*playanimal)[i].play("Walk_end"); } } -void testApp::endGame(){ +void testApp::hangUp(){ string score=songs[currentsong]->getName()+":"+ofToString(((float)songs[currentsong]->getCurrentTime())*.001)+(songs[currentsong]->isFinished()?":finished":":level "+ofToString(currentlevel)); //printf("current time:%i length:%i \n",songs[currentsong]->getCurrentTime(),songs[currentsong]->getLength()) printf("score: %s\n",score.c_str()); game.endGame(score); +} +void testApp::endGame(){ + switch (gamestate) { + case GAME_PRACTICE: + case GAME_PRACTICE2: + practiceSong.gameOver(); + break; + case GAME_PLAYING: + songs[currentsong]->gameOver(); + break; + } gamestate=GAME_ENDPLAYING; - tags[6]->play(); + tags[6]->play(1000); segmentStartTime=ofGetElapsedTimeMillis(); - queueWalkOff(); } //-------------------------------------------------------------- @@ -709,7 +733,8 @@ void testApp::keyPressed(int key){ } break; case 'e': - if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE) { + if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE||gamestate==GAME_PRACTICE2) { + hangUp(); endGame(); } break; -- cgit v1.2.3