diff options
Diffstat (limited to 'vfg/src/testApp.cpp')
| -rwxr-xr-x | vfg/src/testApp.cpp | 387 |
1 files changed, 305 insertions, 82 deletions
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index 6001da4..7c596d0 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -5,13 +5,22 @@ guiWindow::~guiWindow(){ cout << "gui window destroyed" << endl; } -void guiWindow::setup(){} +void guiWindow::setup(){ +} void guiWindow::setParent(testApp *p){ parent=p; } void guiWindow::draw(){ + ofDisableAlphaBlending(); parent->gui.draw(); + ofSetColor(255,255,255); + ofDrawBitmapString(ofToString(parent->game.queued)+" in queue", 10,ofGetHeight()-15); + char buf[8]; + sprintf(buf,"%.1f",ofGetFrameRate()); + ofDrawBitmapString(buf, ofGetWidth()-43,ofGetHeight()-15); + ofDrawBitmapString(levelnames[parent->gamestate-1], 10,ofGetHeight()-35); + if (parent->gamestate==GAME_PLAYING) ofDrawBitmapString(parent->songs[parent->currentsong]->getScoreString(),10,ofGetHeight()-55); } void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){ @@ -23,6 +32,9 @@ void guiWindow::windowMoved(int x,int y){ //---------------------------------------------------------------------- void testApp::setup(){ + + game.setup("1122"); + gamepoll=0; songs.push_back(new song("WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Backing_v.2.1.mp3","WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Lead_v.2.1.mp3","VODA_MUS_WEWISHU_Midi_v.2.2.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml")); songs.push_back(new song("DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Backing_v.4.0.mp3","DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Lead_v.4.0.mp3","VODA_MIDI_DeckTheHalls-v.4.0.xml","Lyrics_DeckTheHalls.4.0.xml","Levels_DeckTheHalls.4.0.xml")); @@ -40,6 +52,7 @@ void testApp::setup(){ penguins[1].load("Penguin-Purple.xml"); penguins[2].load("Penguin-Green.xml"); + // temp save time for (int i=0;i<3;i++) raccoons.push_back(Animal()); raccoons[0].load("Raccoon-Blue.xml"); @@ -52,16 +65,25 @@ void testApp::setup(){ tags.push_back(new Tag("Tags/TAG_Level-2.png",3000,0.5,0)); tags.push_back(new Tag("Tags/TAG_Level-3.png",3000,0.5,0)); tags.push_back(new Tag("Tags/TAG_Level-4.png",3000,0.5,0)); + tags.push_back(new Tag("Tags/PreGame-Practice.png",3000,0.5,0)); + tags.push_back(new Tag("Tags/Game-Over.png",3000,0.5,0)); + tags.push_back(new Tag("Tags/Thanks-NEW.png",3000,0.5,0)); + logos.push_back(new Billboard("Logo-VF.png",0.5,0.0)); logos.push_back(new Billboard("Logo-DCC.png",0.36,0.855)); lyricspanel=new Billboard("Lyrics-panel.png",0.5,0.703); - banner.load("Ribbon/Dublin/Ribbon_%05i.png",500); + banner.load("Ribbon/Dublin/Ribbon-Dublin_%05i.png",500); banner.setAnchorPercent(0.5,0.0); banner.setFrameRate(50); banner.play(); + + wirebirds.load("Birds-with-Wire/Birds-with-Wire_%05i.png",125); + wirebirds.setAnchorPercent(0.5,0.5); + wirebirds.setFrameRate(50); + wirebirds.play(); //loadanimals("Raccoons"); playanimal =&penguins; @@ -72,23 +94,34 @@ void testApp::setup(){ //release: commented out: 436m 256m //508fr 1.4s load in use: 836m 443m + + //cd /home/tim/workspace/VFxmas/vfg/bin/data + //mount -t tmpfs -o size=64M tmpfs /RAM + //cp *.m* RAM - intro.loadMovie("Game-Demo_v3.mp4"); + intro.loadMovie("RAM/Game-Demo_v5.mp4"); intro.setLoopState(OF_LOOP_NONE); + intro.setVolume(0.0); - advert.loadMovie("GW2003761_GRY-VFBR055-060_MPEG_hi.mpg"); + advert.loadMovie("RAM/GW2003761_GRY-VFBR055-060_MPEG_hi.mov"); advert.setLoopState(OF_LOOP_NONE); + advert.setVolume(1.0); - background.loadMovie("Background_v3.mp4"); + background.loadMovie("RAM/Background_v3.mp4"); background.setLoopState(OF_LOOP_NORMAL); background.play(); + + backgroundmusic.loadSound("VODA_MUS_Pre-Game-Music_v.1.1.mp3"); + backgroundmusic.setLoop(true); + backgroundmusic.play(); + backgroundmusic.setVolume(1.0); vignette.loadImage("Vignette.png"); showFPS=true; - showVis=true; + showVis=false; fullscreenoutput=false; - fadelength=1000; + fadelength=3000; segmentStartTime=0; currentsong=0; nextsong=0; @@ -137,26 +170,29 @@ void testApp::loadanimals(string which) { void testApp::exit(){ delete lyricspanel; + backgroundmusic.unloadSound(); } //-------------------------------------------------------------- void testApp::update(){ int ret=game.update(); + if (ofGetElapsedTimeMillis()-gamepoll>5000) { + game.requestStatus(); + gamepoll=ofGetElapsedTimeMillis(); + } if (ret==1000) { - currentlevel=0; - currentsong=nextsong; - songs[currentsong]->setTimeframe(timescale); - songs[currentsong]->setFlakeThresh(threshStart,threshEnd); - songs[currentsong]->setKeyThresh(keyThresh); - songs[currentsong]->preRoll(5000); - tags[0]->play(); - nextsong=(nextsong+1)%songs.size(); - gamestate=GAME_PRACTICE; + activatePractice(); } else if (ret>48&&ret<52) { songs[currentsong]->playerControl(ret-49); + practiceSong.playerControl(ret-49); (*playanimal)[ret-49].playNow("Clap"); } + else if (ret>51&&ret<55) { + songs[currentsong]->playerControl(ret-52); + practiceSong.playerControl(ret-52); + (*playanimal)[ret-52].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++) { @@ -177,21 +213,23 @@ void testApp::update(){ case GAME_PLAYING: case GAME_ENDPLAYING: case GAME_ENDINGINTRO: - case GAME_ENDINGADVERT: case GAME_PRACTICE: - background.update(); - banner.update(); + background.update(); + banner.update(); + wirebirds.update(); break; case GAME_STARTINGINTRO: background.update(); case GAME_INTRO: - intro.update(); - break; + intro.update(); + break; case GAME_STARTINGADVERT: - background.update(); + case GAME_ENDINGADVERT: + background.update(); + banner.update(); case GAME_ADVERT: - advert.update(); - break; + advert.update(); + break; } } @@ -210,8 +248,8 @@ void testApp::update(){ */ //-------------------------------------------------------------- void testApp::drawBackgroundLayers(){ + float hOffs=(ofGetWidth()-ofGetHeight())/2; background.draw(hOffs,0,ofGetHeight(),ofGetHeight()); - scale=ofGetHeight()/1080.0f; ofEnableAlphaBlending(); vignette.draw(hOffs,0,ofGetHeight(),ofGetHeight()); ofDisableAlphaBlending(); @@ -221,13 +259,110 @@ void testApp::draw(){ ofDisableAlphaBlending(); ofSetColor(255,255,255); float hOffs=(ofGetWidth()-ofGetHeight())/2; - float bannerscale,scale; //this old chestnut + float scale=ofGetHeight()/1080.0f; + float bannerscale,aspect,wOffs; //this old chestnut + float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength; //same variable used in all segments + switch(gamestate) { - + case GAME_STARTINGINTRO: + case GAME_INTRO: + case GAME_ENDINGINTRO: case GAME_READY: + case GAME_STARTINGADVERT: + case GAME_ADVERT: + case GAME_ENDINGADVERT: + case GAME_STARTPLAYING: + case GAME_PRACTICE: case GAME_PLAYING: + case GAME_ENDPLAYING: + break; + } + //draw backgrounds + switch(gamestate) { + case GAME_STARTINGINTRO: + case GAME_INTRO: + case GAME_ENDINGINTRO: + intro.draw(hOffs,0,ofGetHeight(),ofGetHeight()); + if (intro.getCurrentFrame()==intro.getTotalNumFrames()) { + gamestate=GAME_READY; + } + break; + case GAME_READY: + case GAME_STARTPLAYING: + case GAME_PRACTICE: + case GAME_PLAYING: + case GAME_ENDPLAYING: drawBackgroundLayers(); - + break; + case GAME_STARTINGADVERT: + if (segamt<0.5) { + ofEnableAlphaBlending(); + ofSetColor(255,255,255,255-(segamt*510)); + drawBackgroundLayers(); + break; + } + else if (segamt>1.0) { + gamestate=GAME_ADVERT; + } + else { + //if (!advert.isPlaying()) advert.play(); + ofEnableAlphaBlending(); + ofSetColor(255,255,255,((segamt-0.5)*510)); + } + case GAME_ADVERT: + case GAME_ENDINGADVERT: + if (gamestate==GAME_ENDINGADVERT) { + if (segamt<0.5) { + ofEnableAlphaBlending(); + segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime))/fadelength; + ofSetColor(255,255,255,255-(segamt*510)); + } + else if (segamt>1.0) { + gamestate=GAME_READY; + ofSetColor(255,255,255); + ofDisableAlphaBlending(); + drawBackgroundLayers(); + break; + } + else { + ofDisableAlphaBlending(); + ofSetColor(((segamt-0.5)*510),((segamt-0.5)*510),((segamt-0.5)*510)); + drawBackgroundLayers(); + break; + } + } + aspect=advert.getHeight()/advert.getWidth(); + wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5; + advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect); + ofDisableAlphaBlending(); //may have been turned on during intro + + break; + + } + + //draw game action + switch(gamestate) { + case GAME_STARTINGADVERT: + if (segamt<0.5) { + ofEnableAlphaBlending(); + ofSetColor(255,255,255,255-(segamt*510)); + } + else break; + case GAME_ENDINGADVERT: + if (segamt>0.5) { + ofEnableAlphaBlending(); + ofSetColor(255,255,255,((segamt-0.5)*510)); + } + else break; + case GAME_READY: + for (int i=0;i<3;i++) { + //break up standing around movement + if (ofRandom(1.0)<.002) (*playanimal)[i].play("Shuffle"); + } + case GAME_PLAYING: + case GAME_PRACTICE: + case GAME_ENDPLAYING: + ofEnableAlphaBlending(); if (songs[currentsong]->isPlaying) { ofSetColor(255,255,255); if (showVis) songs[currentsong]->drawNotes(hOffs); @@ -236,78 +371,138 @@ void testApp::draw(){ int hit=songs[currentsong]->hitNote(); if (hit>-1) (*playanimal)[hit].play("Catch"); } - else { - if (gamestate==GAME_PLAYING) { - game.endGame("GOOD!"); - gamestate=GAME_READY; + else if (gamestate==GAME_PRACTICE) { + int missed=practiceSong.missedNote(); + if (missed>-1) (*playanimal)[missed].playNow("Shudder"); + int hit=practiceSong.hitNote(); + if (hit>-1) (*playanimal)[hit].play("Catch"); + } - } - ofSetColor(255,255,255); for (int i=0;i<3;i++) (*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale); if (songs[currentsong]->isPlaying) { - ofSetColor(255,255,255); lyricspanel->draw(ofGetWidth()*0.5,ofGetHeight()*gridY[1],scale); songs[currentsong]->draw(hOffs,scale); } - else { - ofDrawBitmapString("game over!", (ofGetWidth()/2)-25,(ofGetHeight()/2)-5); - logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); - } - ofSetColor(255,255,255); - for (int i=0;i<tags.size();i++) { - if (tags[i]->isPlaying) tags[i]->draw(0.5f*ofGetWidth(),0,scale); + else if (gamestate==GAME_PRACTICE) { + practiceSong.draw(hOffs,scale); } - logos[0]->draw((gridX[0]*ofGetHeight())+hOffs,0,scale); - bannerscale=songs[currentsong]->isPlaying?scale*(1.0f-(max(0.0,min(((float)songs[currentsong]->getCurrentTime())*.001,1.0))*0.325)):scale; + } + //draw characters + switch(gamestate) { + case GAME_STARTINGADVERT: + if (segamt<0.5) { + ofEnableAlphaBlending(); + ofSetColor(255,255,255,255-(segamt*510)); + } + else break; + case GAME_ENDINGADVERT: + if (segamt>0.5) { + ofEnableAlphaBlending(); + ofSetColor(255,255,255,((segamt-0.5)*510)); + } + else break; + case GAME_READY: + //DCC LOGO + logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); + case GAME_STARTPLAYING: + case GAME_PRACTICE: + case GAME_PLAYING: + case GAME_ENDPLAYING: + ofEnableAlphaBlending(); + if (gamestate!=GAME_STARTINGADVERT&&gamestate!=GAME_ENDINGADVERT) ofSetColor(255,255,255); + for (int i=0;i<tags.size();i++) { + if (tags[i]->isPlaying) tags[i]->draw(0.5f*ofGetWidth(),0,scale); + } + logos[0]->draw((gridX[0]*ofGetHeight())+hOffs,0,scale); + break; + } + //draw banner, DCC logo and wirebirds + bannerscale=scale; + ofSetColor(255,255,255); + 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()*0.65,scale); + segamt=1.0; + ofEnableAlphaBlending(); banner.draw(ofGetWidth()*0.5,0,bannerscale); - char buf[30]; - sprintf(buf,"%.1f",ofGetFrameRate()); - if (showFPS) ofDrawBitmapString(buf, hOffs+ofGetHeight()-50,(ofGetHeight()*gridY[1])-3); - break; - case GAME_INTRO: - intro.draw(hOffs,0,ofGetHeight(),ofGetHeight()); - if (intro.getCurrentFrame()==intro.getTotalNumFrames()) { - gamestate=GAME_READY; - } break; case GAME_STARTINGADVERT: - float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime))/fadelength; if (segamt<0.5) { ofEnableAlphaBlending(); - ofSetColor(255,255,255,255-(segamt*512)); - break; - } - else if (segamt>1.0) { - gamestate=GAME_ADVERT; - break; + ofSetColor(255,255,255,255-(segamt*510)); } - else { - if (!advert.isPlaying()) advert.play(); + else break; + case GAME_ENDINGADVERT: + if (segamt>0.5) { ofEnableAlphaBlending(); - ofSetColor(255,255,255,((segamt-0.5)*512)); + ofSetColor(255,255,255,((segamt-0.5)*510)); } + else break; + case GAME_READY: + ofEnableAlphaBlending(); + banner.draw(ofGetWidth()*0.5,0,bannerscale); + break; + case GAME_STARTPLAYING: + case GAME_PLAYING: + bannerscale=scale*0.675; + ofEnableAlphaBlending(); + banner.draw(ofGetWidth()*0.5,0,bannerscale); + break; + case GAME_ENDPLAYING: + bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); + ofEnableAlphaBlending(); + banner.draw(ofGetWidth()*0.5,0,bannerscale); + break; + } + //switch states: + switch(gamestate) { + case GAME_STARTINGINTRO: + case GAME_INTRO: + case GAME_ENDINGINTRO: + case GAME_READY: + break; + case GAME_STARTINGADVERT: + backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0))); case GAME_ADVERT: - case GAME_ENDINGADVERT: - if (gamestate==GAME_ENDINGADVERT) - float aspect=advert.getHeight()/advert.getWidth(); - float wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5; - advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect); - ofDisableAlphaBlending(); //may have been turned on during intro - if (advert.getCurrentFrame()==advert.getTotalNumFrames()) { + if (advert.getCurrentFrame()==advert.getTotalNumFrames()&&gamestate==GAME_ADVERT) { gamestate=GAME_ENDINGADVERT; segmentStartTime=ofGetElapsedTimeMillis(); } break; + case GAME_ENDINGADVERT: + backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0)); + case GAME_STARTPLAYING: + case GAME_PRACTICE: + break; + case GAME_PLAYING: + backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0))); + if (!songs[currentsong]->isPlaying) { + game.endGame("GOOD!"); + gamestate=GAME_ENDPLAYING; + tags[6]->play(); + segmentStartTime=ofGetElapsedTimeMillis(); + } + break; + case GAME_ENDPLAYING: + backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0)); + if (segamt>1.0) { + gamestate=GAME_READY; + switchAnimals(); + } + break; } - } + + //-------------------------------------------------------------- void testApp::keyPressedEvent(ofKeyEventArgs &args) { //printf("window key pressed: %i (%c)\n",args.key,args.key); keyPressed(args.key); } void testApp::keyPressed(int key, ofxFenster* win){ - //printf("window sent %i\n",key); + //xprintf("window sent %i\n",key); if(key == '='){ fullscreenoutput=!fullscreenoutput; win->setFullscreen(fullscreenoutput); @@ -316,25 +511,50 @@ void testApp::keyPressed(int key, ofxFenster* win){ else keyPressed(key); } //-------------------------------------------------------------- +void testApp::activateGame(){ + segmentStartTime=ofGetElapsedTimeMillis(); + currentlevel=0; + currentsong=nextsong; + songs[currentsong]->setTimeframe(timescale); + songs[currentsong]->setFlakeThresh(threshStart,threshEnd); + songs[currentsong]->setKeyThresh(keyThresh); + songs[currentsong]->play(); + tags[0]->play(); + nextsong=(nextsong+1)%songs.size(); + gamestate=GAME_PLAYING; +} +void testApp::activatePractice(){ + segmentStartTime=ofGetElapsedTimeMillis(); + gamestate=GAME_PRACTICE; + currentlevel=0; + practiceSong.setTimeframe(timescale); + practiceSong.setFlakeThresh(threshStart,threshEnd); + practiceSong.setKeyThresh(keyThresh); + practiceSong.play(); + tags[5]->play(); +} +void testApp::switchAnimals(){ + if (playanimal==&raccoons) playanimal=&penguins; + else playanimal =&raccoons; +} +//-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key) { + case 'x': + if (gamestate==GAME_READY||gamestate==GAME_PRACTICE) { + activatePractice(); + } + break; case ' ': - if (gamestate==GAME_READY) { - currentlevel=0; - currentsong=nextsong; - songs[currentsong]->setTimeframe(timescale); - songs[currentsong]->setFlakeThresh(threshStart,threshEnd); - songs[currentsong]->setKeyThresh(keyThresh); - songs[currentsong]->preRoll(5000); - tags[0]->play(); - nextsong=(nextsong+1)%songs.size(); - gamestate=GAME_PRACTICE; + if (gamestate==GAME_PRACTICE) { + activateGame(); } break; case '1': case '2': case '3': songs[currentsong]->playerControl(key-'1'); + practiceSong.playerControl(key-'1'); (*playanimal)[key-'1'].playNow("Clap"); break; case 's': @@ -350,6 +570,7 @@ void testApp::keyPressed(int key){ break; case 'q': if (gamestate==GAME_READY) { + intro.firstFrame(); intro.play(); gamestate=GAME_INTRO; } @@ -358,6 +579,8 @@ void testApp::keyPressed(int key){ if (gamestate==GAME_READY) { segmentStartTime=ofGetElapsedTimeMillis(); gamestate=GAME_STARTINGADVERT; + advert.firstFrame(); + advert.play(); } break; case 'f': |
