diff options
| author | Comment <tim@gray.(none)> | 2012-12-11 14:17:55 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2012-12-11 14:17:55 +0000 |
| commit | 58be41bc658756a93c7eba19e571484e40459598 (patch) | |
| tree | cb58baceffc0a24fddefdce1d0e5e6c868a32e68 /vfg | |
| parent | dba01ce870165fd8d8a5fea921cb31f7c4e8c25f (diff) | |
final testing sesh
Diffstat (limited to 'vfg')
| -rwxr-xr-x | vfg/src/Asterisk.cpp | 8 | ||||
| -rwxr-xr-x | vfg/src/music.cpp | 2 | ||||
| -rwxr-xr-x | vfg/src/testApp.cpp | 126 | ||||
| -rwxr-xr-x | vfg/src/testApp.h | 9 | ||||
| -rw-r--r-- | vfg/vfg.layout | 10 |
5 files changed, 99 insertions, 56 deletions
diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp index 55a77e0..9d94138 100755 --- a/vfg/src/Asterisk.cpp +++ b/vfg/src/Asterisk.cpp @@ -65,7 +65,6 @@ void Asterisk::setup(string passcode,int millis){ udpConnection.Bind(5000);
udpConnection.SetNonBlocking(true);
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode "+passcode+"\"'");
- state=ASTERISK_WAITING; //for acknowledge
statusPollMillis=millis;
if (statusPollMillis>0) startThread(false, false); // blocking, verbose
}
@@ -83,9 +82,8 @@ void Asterisk::endGame(string score){ if (state==ASTERISK_PLAYING) {
//cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME statuscode "+score+"\"'");
string emsg="ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"hangup request "+playerCode+"\"'";
- scmd(emsg);
+ cmd(emsg);
printf("Asterisk: hanging up %s\n",playerCode.c_str());
- state=ASTERISK_IDLE;
}
}
void Asterisk::cmd(string s) {
@@ -95,7 +93,7 @@ void Asterisk::cmd(string s) { file = popen(s.c_str(), "re"); //"e" seems necessary for non blocking but with it getting crash when dequeuing. can't seem to trace it
filenum=fileno(file);
fcntl(filenum, F_SETFL, O_NONBLOCK); - state=ASTERISK_WAITING;
+ state=ASTERISK_WAITING;
} void Asterisk::scmd(string s) {
@@ -106,7 +104,7 @@ void Asterisk::scmd(string s) { filenum=fileno(file);
fcntl(filenum, F_SETFL, O_NONBLOCK); //printf("close file\n");
- pclose(file);
+ pclose(file); //is blocking!
} diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 4cddab9..68dca7f 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -304,6 +304,8 @@ void song::preRoll(long preroll) { isPreroll=true;
isPlaying=true;
gameover=false;
+ melody.setVolume(1.0f);
+ backing.setVolume(1.0f);
}
void song::drawNotes(float hOffs){
notes.drawNotes(hOffs,&levels);
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; diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index 82b25a5..d44973c 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -50,6 +50,7 @@ the 2nd time you play , if you 'die' it doesn't trigger 'end of game', the music #define GAME_PLAYING 10 #define GAME_ENDPLAYING 11 #define GAME_WALKON 12 +#define GAME_ENDTITLE 12 class guiWindow; @@ -79,6 +80,9 @@ class testApp : public ofxFensterListener{ void activatePractice(); void switchAnimals(); void endGame(); + + void queueWalkOff(); + void queueWalkOn(); ofVideoPlayer intro; ofVideoPlayer advert; @@ -146,7 +150,7 @@ public: void draw(); void dragEvent(ofDragInfo dragInfo,ofxFenster* win); void windowMoved(int x, int y); - string levelnames[12]={ + string levelnames[13]={ "STARTINGINTRO", "INTRO", "ENDINGINTRO", @@ -158,7 +162,8 @@ public: "PRACTICE", "PLAYING", "ENDPLAYING", - "WALKON" + "WALKON", + "ENDTITLE" }; }; diff --git a/vfg/vfg.layout b/vfg/vfg.layout index c534f02..2fbc6b6 100644 --- a/vfg/vfg.layout +++ b/vfg/vfg.layout @@ -5,13 +5,13 @@ <Cursor position="80" topLine="0" /> </File> <File name="src/Asterisk.cpp" open="1" top="0" tabpos="4"> - <Cursor position="484" topLine="21" /> + <Cursor position="484" topLine="0" /> </File> <File name="src/Asterisk.h" open="0" top="0" tabpos="3"> <Cursor position="106" topLine="23" /> </File> - <File name="src/Puppet.cpp" open="1" top="1" tabpos="8"> - <Cursor position="1376" topLine="28" /> + <File name="src/Puppet.cpp" open="1" top="0" tabpos="8"> + <Cursor position="1376" topLine="0" /> </File> <File name="src/Puppet.h" open="1" top="0" tabpos="7"> <Cursor position="789" topLine="14" /> @@ -31,7 +31,7 @@ <File name="src/testApp.cpp" open="1" top="0" tabpos="3"> <Cursor position="8311" topLine="218" /> </File> - <File name="src/testApp.h" open="1" top="0" tabpos="2"> - <Cursor position="1353" topLine="23" /> + <File name="src/testApp.h" open="1" top="1" tabpos="2"> + <Cursor position="1353" topLine="19" /> </File> </CodeBlocks_layout_file> |
