From 11322afc79c2d36d5edecd0e6b38186f9f2dd867 Mon Sep 17 00:00:00 2001 From: Comment Date: Thu, 6 Dec 2012 11:34:28 +0000 Subject: character transitions --- vfg/bin/data/Levels_DeckTheHalls.4.0.xml | 2 +- vfg/bin/data/Levels_DingDong.2.2.xml | 2 +- vfg/bin/data/Levels_WeWishYou.2.1.xml | 2 +- vfg/src/Animal.cpp | 13 ----- vfg/src/Animal.h | 19 ------- vfg/src/music.cpp | 11 +++- vfg/src/music.h | 21 +++++--- vfg/src/testApp.cpp | 86 +++++++++++++++++++++++--------- vfg/src/testApp.h | 15 +++--- vfg/vfg.cbp | 6 --- vfg/vfg.layout | 14 +++--- 11 files changed, 105 insertions(+), 86 deletions(-) delete mode 100644 vfg/src/Animal.cpp delete mode 100644 vfg/src/Animal.h diff --git a/vfg/bin/data/Levels_DeckTheHalls.4.0.xml b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml index 5228895..9243097 100755 --- a/vfg/bin/data/Levels_DeckTheHalls.4.0.xml +++ b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml @@ -1,5 +1,5 @@ - + diff --git a/vfg/bin/data/Levels_DingDong.2.2.xml b/vfg/bin/data/Levels_DingDong.2.2.xml index 0636305..1bbc101 100755 --- a/vfg/bin/data/Levels_DingDong.2.2.xml +++ b/vfg/bin/data/Levels_DingDong.2.2.xml @@ -1,5 +1,5 @@ - + diff --git a/vfg/bin/data/Levels_WeWishYou.2.1.xml b/vfg/bin/data/Levels_WeWishYou.2.1.xml index 8f037af..97c7d66 100755 --- a/vfg/bin/data/Levels_WeWishYou.2.1.xml +++ b/vfg/bin/data/Levels_WeWishYou.2.1.xml @@ -1,5 +1,5 @@ - + diff --git a/vfg/src/Animal.cpp b/vfg/src/Animal.cpp deleted file mode 100644 index 815aa81..0000000 --- a/vfg/src/Animal.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Animal.h" - -Animal::Animal() -{ - //ctor -} - -Animal::~Animal() -{ - //dtor -} -void Animal::update(){ -} diff --git a/vfg/src/Animal.h b/vfg/src/Animal.h deleted file mode 100644 index 4155901..0000000 --- a/vfg/src/Animal.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ANIMAL_H -#define ANIMAL_H - -#include "ofMain.h" -#include "ofxXmlSettings.h" -#include "Puppet.h" - - -class Animal: public Puppet -{ - public: - Animal(); - virtual ~Animal(); - void update(); - protected: - private: -}; - -#endif // ANIMAL_H diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index e715892..a2e7020 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -307,7 +307,16 @@ void song::drawNotes(float hOffs){ } string song::getScoreString(){ int songTime=ofGetElapsedTimeMillis()-startTime; - return ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)); + return ofToString((float)songTime/1000.0f,1)+": level "+ofToString(levels.getLevel(songTime))+": lives "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)); +} +string song::getName(){ + return levels.name; +} +int song::getLength(){ + return levels.length; +} +bool song::isFinished(){ + return (getCurrentTime()>=getLength()); } void song::draw(float hOffs,float scale){ int songTime=ofGetElapsedTimeMillis()-startTime; diff --git a/vfg/src/music.h b/vfg/src/music.h index e4e8601..1aa956a 100755 --- a/vfg/src/music.h +++ b/vfg/src/music.h @@ -17,7 +17,8 @@ class levelscore { if( !XML.loadFile(filename) ){ printf("unable to load %s check data/ folder\n",filename.c_str()); }else{ - int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0); + int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0); + name=XML.getAttribute("VFxmas", "name","",0); length=XML.getAttribute("VFxmas", "length",0,0)*multiplier; if(XML.pushTag("VFxmas")) { for (int i=0;i levels; - + }; //--------------------------------------------------------------------------------------------------------------------------------------------- class note { @@ -181,7 +183,7 @@ class musicscore: public score { map::iterator missedFlake; int timeframe; float nowpoint; - + vector snowflakes; }; @@ -205,16 +207,19 @@ class song { void playerControl(int key); int getLevel(long time); int getCurrentTime(); - string getScoreString(); - + string getScoreString(); + string getName(); + int getLength(); + bool isFinished(); + musicscore notes; private: ofSoundPlayer backing; ofSoundPlayer melody; lyricscore lyrics; - + levelscore levels; - long startTime; + int startTime; bool isPreroll,isPractice; int fThreshStart,fThreshEnd; diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index 986673c..0e8d31e 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -46,14 +46,14 @@ void testApp::setup(){ //printf("we wish you a merry xmas:\n"); //songs[0]->notes.printNotes(); - for (int i=0;i<3;i++) penguins.push_back(Animal()); + for (int i=0;i<3;i++) penguins.push_back(Puppet()); penguins[0].load("Penguin-Blue.xml"); 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()); + for (int i=0;i<3;i++) raccoons.push_back(Puppet()); raccoons[0].load("Raccoon-Blue.xml"); raccoons[1].load("Raccoon-Purple.xml"); raccoons[2].load("Raccoon-Green.xml"); @@ -138,7 +138,9 @@ void testApp::setup(){ gui.add(ts.setup("timescale",timescale,0,10000,255)); keyThresh=1500; gui.add(kT.setup("keythresh",keyThresh,0,4000,255)); - gui.add(showWire.setup("birdwire",true)); + birdpoint=0.6; + gui.add(bP.setup("wire level",birdpoint,0.5,0.7,255)); + gui.add(showWire.setup("wire",true)); ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW); win->setWindowTitle("config"); @@ -152,7 +154,7 @@ void testApp::setup(){ void testApp::loadanimals(string which) { playanimals.clear(); - for (int i=0;i<3;i++) playanimals.push_back(Animal()); + for (int i=0;i<3;i++) playanimals.push_back(Puppet()); if (which=="Penguins") { playanimals[0].load("Penguin-Blue.xml"); @@ -200,9 +202,6 @@ void testApp::update(){ currentlevel++; printf("finished level %i!\n",currentlevel); } - for (int i=0;i<3;i++) { - (*playanimal)[i].update(); - } switch(gamestate) { case GAME_READY: case GAME_STARTPLAYING: @@ -256,7 +255,7 @@ void testApp::draw(){ ofSetColor(255,255,255); float hOffs=(ofGetWidth()-ofGetHeight())/2; float scale=ofGetHeight()/1080.0f; - float bannerscale,aspect,wOffs; //this old chestnut + float bannerscale,aspect,wOffs,seg; //this old chestnut float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength; //same variable used in all segments switch(gamestate) { @@ -271,6 +270,7 @@ void testApp::draw(){ case GAME_PRACTICE: case GAME_PLAYING: case GAME_ENDPLAYING: + case GAME_WALKON: break; } //draw backgrounds @@ -288,6 +288,7 @@ void testApp::draw(){ case GAME_PRACTICE: case GAME_PLAYING: case GAME_ENDPLAYING: + case GAME_WALKON: drawBackgroundLayers(); break; case GAME_STARTINGADVERT: @@ -357,7 +358,6 @@ void testApp::draw(){ } case GAME_PLAYING: case GAME_PRACTICE: - case GAME_ENDPLAYING: ofEnableAlphaBlending(); if (songs[currentsong]->isPlaying) { ofSetColor(255,255,255); @@ -382,8 +382,25 @@ void testApp::draw(){ else if (gamestate==GAME_PRACTICE) { practiceSong.draw(hOffs,scale); } + break; + case GAME_ENDPLAYING: + //6 seconds to walk in / out -> 12 seconds turnaround + //frames to start/cycle/stop walking + //penguin: 11,35,11 + //raccoon: 20,39,43r + ofEnableAlphaBlending(); + seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001; + wOffs=hOffs+(0.7*ofGetWidth()*seg); + for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale); + break; + case GAME_WALKON: + ofEnableAlphaBlending(); + seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001; + wOffs=hOffs+(0.7*ofGetWidth()*(1.0f-seg)); + for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale); + break; } - //draw characters + //draw tags and logos switch(gamestate) { case GAME_STARTINGADVERT: if (segamt<0.5) { @@ -398,12 +415,11 @@ void testApp::draw(){ } 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: + case GAME_WALKON: ofEnableAlphaBlending(); if (gamestate!=GAME_STARTINGADVERT&&gamestate!=GAME_ENDINGADVERT) ofSetColor(255,255,255); for (int i=0;idraw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); ofEnableAlphaBlending(); banner.draw(ofGetWidth()*0.5,0,bannerscale); @@ -476,19 +495,22 @@ void testApp::draw(){ 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(); + endGame(); } break; case GAME_ENDPLAYING: backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0)); - if (segamt>1.0) { - gamestate=GAME_READY; + if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) { + gamestate=GAME_WALKON; switchAnimals(); } break; + case GAME_WALKON: + if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) { + gamestate=GAME_READY; + segmentStartTime=ofGetElapsedTimeMillis(); + } + break; } } @@ -534,6 +556,25 @@ void testApp::switchAnimals(){ if (playanimal==&raccoons) playanimal=&penguins; else playanimal =&raccoons; } +void testApp::endGame(){ + 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); + gamestate=GAME_ENDPLAYING; + tags[6]->play(); + segmentStartTime=ofGetElapsedTimeMillis(); + //6 seconds to walk in / out -> 12 seconds turnaround + //frames to start/cycle/stop walking + //penguin: 11,35,11 + //raccoon: 20,39,43 + //penguins: start + 289 = 8.25 + //raccoons: start + 280 = 7.17 + for (int i=0;i<3;i++) { + (*playanimal)[i].play("Walk_start"); + for (int j=0;j<9;j++) (*playanimal)[i].play("Walking"); + } +} //-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key) { @@ -560,9 +601,8 @@ void testApp::keyPressed(int key){ } break; case 'e': - if (gamestate==GAME_PLAYING) { - game.endGame("GOOD!"); - gamestate=GAME_READY; + if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE) { + endGame(); } break; case 'q': diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index d4a9627..0cc0942 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -8,7 +8,6 @@ #include "music.h" #include "Asterisk.h" #include "Puppet.h" -#include "Animal.h" #include "Tag.h"; /* @@ -48,6 +47,7 @@ ramdisk for movies #define GAME_PRACTICE 9 #define GAME_PLAYING 10 #define GAME_ENDPLAYING 11 +#define GAME_WALKON 12 class guiWindow; @@ -76,6 +76,7 @@ class testApp : public ofxFensterListener{ void activateGame(); void activatePractice(); void switchAnimals(); + void endGame(); ofVideoPlayer intro; ofVideoPlayer advert; @@ -88,14 +89,14 @@ class testApp : public ofxFensterListener{ song practiceSong; - vector penguins; - vector raccoons; + vector penguins; + vector raccoons; - //vector > animals; + //vector > animals; - //vector playanimals; + //vector playanimals; - vector* playanimal; + vector* playanimal; vector tags; vector logos; @@ -128,6 +129,8 @@ class testApp : public ofxFensterListener{ ofxParameter timescale; ofxIntSlider kT; ofxParameter keyThresh; + ofxFloatSlider bP; + ofxParameter birdpoint; ofxToggle showWire; }; diff --git a/vfg/vfg.cbp b/vfg/vfg.cbp index cc07b3b..408e357 100755 --- a/vfg/vfg.cbp +++ b/vfg/vfg.cbp @@ -33,12 +33,6 @@ - - - - diff --git a/vfg/vfg.layout b/vfg/vfg.layout index e3ee66d..06595b0 100644 --- a/vfg/vfg.layout +++ b/vfg/vfg.layout @@ -5,7 +5,7 @@ - + @@ -13,8 +13,8 @@ - - + + @@ -25,13 +25,13 @@ - - + + - + - + -- cgit v1.2.3