diff options
| author | Comment <tim@gray.(none)> | 2012-12-06 11:34:28 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2012-12-06 11:34:28 +0000 |
| commit | 11322afc79c2d36d5edecd0e6b38186f9f2dd867 (patch) | |
| tree | 596cc518a40f9625c4049db278b067d450626ed5 /vfg/src | |
| parent | 8fe8572729f186269b02ac2bb149fe9a25671cae (diff) | |
character transitions
Diffstat (limited to 'vfg/src')
| -rw-r--r-- | vfg/src/Animal.cpp | 13 | ||||
| -rw-r--r-- | vfg/src/Animal.h | 19 | ||||
| -rwxr-xr-x | vfg/src/music.cpp | 11 | ||||
| -rwxr-xr-x | vfg/src/music.h | 21 | ||||
| -rwxr-xr-x | vfg/src/testApp.cpp | 86 | ||||
| -rwxr-xr-x | vfg/src/testApp.h | 15 |
6 files changed, 95 insertions, 70 deletions
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<XML.getNumTags("Level");i++) {
@@ -74,10 +75,11 @@ class levelscore { }
return 2<<20; // a big number
}
- int length;
+ int length; + string name;
private:
map<int,int> levels;
-
+
};
//---------------------------------------------------------------------------------------------------------------------------------------------
class note {
@@ -181,7 +183,7 @@ class musicscore: public score { map<int,flake*>::iterator missedFlake;
int timeframe; float nowpoint;
-
+
vector<Puppet> 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;i<tags.size();i++) { @@ -419,7 +435,7 @@ void testApp::draw(){ 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.6,scale); + wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale); segamt=1.0; ofEnableAlphaBlending(); banner.draw(ofGetWidth()*0.5,0,bannerscale); @@ -442,12 +458,15 @@ void testApp::draw(){ break; case GAME_STARTPLAYING: case GAME_PLAYING: - if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*0.6,scale); + 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: + case GAME_WALKON: + //DCC LOGO + logos[1]->draw((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<Animal> penguins; - vector<Animal> raccoons; + vector<Puppet> penguins; + vector<Puppet> raccoons; - //vector<vector<Animal> > animals; + //vector<vector<Puppet> > animals; - //vector<Animal> playanimals; + //vector<Puppet> playanimals; - vector<Animal>* playanimal; + vector<Puppet>* playanimal; vector<Tag*> tags; vector<Billboard*> logos; @@ -128,6 +129,8 @@ class testApp : public ofxFensterListener{ ofxParameter<int> timescale; ofxIntSlider kT; ofxParameter<int> keyThresh; + ofxFloatSlider bP; + ofxParameter<float> birdpoint; ofxToggle showWire; }; |
