summaryrefslogtreecommitdiff
path: root/vfg/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/testApp.cpp')
-rwxr-xr-xvfg/src/testApp.cpp126
1 files changed, 82 insertions, 44 deletions
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 3e711f2..a325064 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -49,7 +49,7 @@ void testApp::setup(){
//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_test.xml"));
- songs.push_back(new song("SilentNight/VODA_SilentNight_Backing_v.1.1.1.mp3","SilentNight/VODA_SilentNight_Melody_v.1.1.1.mp3","VODA_SilentNight_Midi_v.1.1.1.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml"));
+ //songs.push_back(new song("SilentNight/VODA_SilentNight_Backing_v.1.1.1.mp3","SilentNight/VODA_SilentNight_Melody_v.1.1.1.mp3","VODA_SilentNight_Midi_v.1.1.1.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml"));
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"));
songs.push_back(new song("DingDong.v.2.2/VODA_MUS_DingDong_Backing_v.2.2.mp3","DingDong.v.2.2/VODA_MUS_DingDong_Melody_v.2.2.mp3","VODA_MIDI_DingDong_v.2.2.xml","Lyrics_DingDong.2.2.xml","Levels_DingDong.2.2.xml"));
@@ -298,9 +298,9 @@ void testApp::draw(){
switch(gamestate) {
case GAME_STARTINGINTRO:
case GAME_INTRO:
- case GAME_ENDINGINTRO:
intro.draw(hOffs,0,ofGetHeight(),ofGetHeight());
break;
+ case GAME_ENDINGINTRO:
case GAME_READY:
case GAME_STARTPLAYING:
case GAME_PRACTICE:
@@ -374,6 +374,14 @@ void testApp::draw(){
(*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
}
break;
+ case GAME_INTRO:
+ ofEnableAlphaBlending();
+ seg=(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)/6;
+ if (seg<1.0f) {
+ wOffs=hOffs+(0.75*ofGetWidth()*seg);
+ for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
+ }
+ break;
case GAME_PRACTICE:
ofEnableAlphaBlending();
missed=practiceSong.missedNote();
@@ -401,14 +409,15 @@ void testApp::draw(){
//raccoon: 20,39,43r
ofEnableAlphaBlending();
seg=(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)/6;
- wOffs=hOffs+(0.7*ofGetWidth()*seg);
+ wOffs=hOffs+(0.75*ofGetWidth()*seg);
for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
songs[currentsong]->draw(hOffs,scale);//allows the song to fade its volume out and stop playing, last notes to play out
break;
case GAME_WALKON:
+ case GAME_ENDINGINTRO:
ofEnableAlphaBlending();
seg=(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)/6;
- wOffs=hOffs-(0.7*ofGetWidth()*(1.0f-seg));
+ wOffs=hOffs-(0.75*ofGetWidth()*(1.0f-seg));
for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
break;
}
@@ -428,6 +437,7 @@ void testApp::draw(){
ofSetColor(255,255,255,((segamt-0.5)*510));
}
else break;
+ case GAME_ENDINGINTRO:
case GAME_READY:
case GAME_STARTPLAYING:
case GAME_PRACTICE:
@@ -467,6 +477,7 @@ void testApp::draw(){
}
else break;
case GAME_READY:
+ case GAME_ENDINGINTRO:
ofEnableAlphaBlending();
banner.draw(ofGetWidth()*0.5,0,bannerscale);
break;
@@ -483,20 +494,39 @@ void testApp::draw(){
banner.draw(ofGetWidth()*0.5,0,bannerscale);
break;
case GAME_WALKON:
- //DCC LOGO
- logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
+ //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);
break;
}
+ //draw blanking edges
+ switch(gamestate) {
+ case GAME_ENDPLAYING:
+ case GAME_WALKON:
+ if (ofGetWidth()>ofGetHeight()) {
+ float slice=(ofGetWidth()-ofGetHeight())/2;
+ ofSetColor(0,0,0);
+ ofRect(0,0,slice,ofGetHeight());
+ ofRect(ofGetWidth()-slice,0,slice,ofGetHeight());
+ ofSetColor(255,255,255);
+ }
+ }
//switch states:
switch(gamestate) {
case GAME_STARTINGINTRO:
case GAME_INTRO:
- case GAME_ENDINGINTRO:
if (intro.getCurrentFrame()==intro.getTotalNumFrames()-1) {
+ gamestate=GAME_ENDINGINTRO;
+ segmentStartTime=ofGetElapsedTimeMillis();
+ queueWalkOn();
+ }
+ break;
+ case GAME_ENDINGINTRO:
+ if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
gamestate=GAME_READY;
+ segmentStartTime=ofGetElapsedTimeMillis();
}
break;
case GAME_READY:
@@ -530,37 +560,15 @@ void testApp::draw(){
gamestate=GAME_WALKON;
segmentStartTime=ofGetElapsedTimeMillis();
switchAnimals();
- //work out offet and schedule transition to finish at the end of 6 seconds
- //6 seconds to walk in / out -> 12 seconds turnaround
- //frames to start/cycle/stop walking
- //penguin: 11,35,11
- //raccoon: 20,39,43
-
- //penguins: 8 cycles + end = 291, diff 180ms (+ 1 frame per cycle? 0ms)
- //raccoons: 6 cycles + end = diff 230ms (+1 fr/cyc? 90ms)
- for (int i=0;i<3;i++) {
- (*playanimal)[i].clear();
- int numcycles,start;
- if (playanimal==&penguins) {
- start=400; //(of 700 cycle)
- numcycles=7;
- }
- else {
- start=400; //of 780
- numcycles=5;
- }
- (*playanimal)[i].play("Walking",ofGetElapsedTimeMillis()+start);
- for (int j=0;j<numcycles;j++) (*playanimal)[i].play("Walking");
- (*playanimal)[i].play("Walk_end");
- }
+ queueWalkOn();
}
break;
- case GAME_WALKON:
- backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0));
- if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
+ case GAME_WALKON:
+ backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0));
+ if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
gamestate=GAME_READY;
segmentStartTime=ofGetElapsedTimeMillis();
- }
+ }
break;
}
}
@@ -607,6 +615,43 @@ void testApp::switchAnimals(){
if (playanimal==&raccoons) playanimal=&penguins;
else playanimal =&raccoons;
}
+void testApp::queueWalkOff(){
+ //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].playNow("Walk_start");
+ for (int j=0;j<9;j++) (*playanimal)[i].play("Walking");
+ }
+}
+void testApp::queueWalkOn(){
+ //work out offet and schedule transition to finish at the end of 6 seconds
+ //6 seconds to walk in / out -> 12 seconds turnaround
+ //frames to start/cycle/stop walking
+ //penguin: 11,35,11
+ //raccoon: 20,39,43
+
+ //penguins: 8 cycles + end = 291, diff 180ms (+ 1 frame per cycle? 0ms)
+ //raccoons: 6 cycles + end = diff 230ms (+1 fr/cyc? 90ms)
+ for (int i=0;i<3;i++) {
+ (*playanimal)[i].clear();
+ int numcycles,start;
+ if (playanimal==&penguins) {
+ start=400; //(of 700 cycle)
+ numcycles=7;
+ }
+ else {
+ start=400; //of 780
+ numcycles=5;
+ }
+ (*playanimal)[i].play("Walking",ofGetElapsedTimeMillis()+start);
+ for (int j=0;j<numcycles;j++) (*playanimal)[i].play("Walking");
+ (*playanimal)[i].play("Walk_end");
+ }
+}
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())
@@ -615,17 +660,8 @@ void testApp::endGame(){
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].playNow("Walk_start");
- for (int j=0;j<9;j++) (*playanimal)[i].play("Walking");
- }
+ queueWalkOff();
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
@@ -659,6 +695,8 @@ void testApp::keyPressed(int key){
break;
case 'q':
if (gamestate==GAME_READY) {
+ segmentStartTime=ofGetElapsedTimeMillis();
+ queueWalkOff();
intro.firstFrame();
intro.play();
gamestate=GAME_INTRO;