summaryrefslogtreecommitdiff
path: root/vfg/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/testApp.cpp')
-rwxr-xr-xvfg/src/testApp.cpp86
1 files changed, 63 insertions, 23 deletions
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':