diff options
| author | Comment <tim@gray.(none)> | 2012-12-12 10:57:40 +0000 |
|---|---|---|
| committer | Comment <tim@gray.(none)> | 2012-12-12 10:57:40 +0000 |
| commit | 19c84c74efd5b8ffd1fb8184037910c831990d2e (patch) | |
| tree | 19032ce28fed70a58ae95cc9937c50681e978b50 | |
| parent | 1db97e28061caec0b3e8ce998b92e1936edbf2e5 (diff) | |
version for galway gig
| -rwxr-xr-x | vfg/src/Asterisk.cpp | 8 | ||||
| -rwxr-xr-x | vfg/src/Asterisk.h | 5 | ||||
| -rwxr-xr-x | vfg/src/Tag.cpp | 28 | ||||
| -rwxr-xr-x | vfg/src/Tag.h | 2 | ||||
| -rwxr-xr-x | vfg/src/testApp.cpp | 69 | ||||
| -rwxr-xr-x | vfg/src/testApp.h | 1 |
6 files changed, 74 insertions, 39 deletions
diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp index 9d94138..1152efa 100755 --- a/vfg/src/Asterisk.cpp +++ b/vfg/src/Asterisk.cpp @@ -30,11 +30,14 @@ gameQ has 1 calls (max unlimited) in 'rrmemory' strategy (8s holdtime, 50s talkt Callers:
1. SIP/sip_proxy-00000045 (wait: 0:06, prio: 0)
*/
-
+int Asterisk::getUpdateTime(){
+ return ofGetElapsedTimeMillis()-cmdtime;
+}
void Asterisk::threadedFunction(){
while( isThreadRunning() != 0 ){ //if (lock()) {
+ cmdtime=ofGetElapsedTimeMillis();
FILE *f = popen("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"queue show gameQ\"'", "re"); //e ??
int fn=fileno(f);
char buf[1000];
@@ -52,7 +55,8 @@ void Asterisk::threadedFunction(){ }
else {
printf("status err: %s\n",buf);
- } + }
+ //unlock(); //}
diff --git a/vfg/src/Asterisk.h b/vfg/src/Asterisk.h index fb6097c..adf76da 100755 --- a/vfg/src/Asterisk.h +++ b/vfg/src/Asterisk.h @@ -31,10 +31,12 @@ class Asterisk: public ofThread virtual ~Asterisk();
void startGame();
void endGame(string score);
+ int getUpdateTime();
int update();
int state;
int queued;
+
protected:
void cmd(string s); void scmd(string s);
@@ -45,7 +47,8 @@ class Asterisk: public ofThread int filenum;
ofxUDPManager udpConnection;
string playerCode;
- int statusPollMillis; + int statusPollMillis;
+ int cmdtime; };
diff --git a/vfg/src/Tag.cpp b/vfg/src/Tag.cpp index bc087e6..0a478a6 100755 --- a/vfg/src/Tag.cpp +++ b/vfg/src/Tag.cpp @@ -4,24 +4,26 @@ void Billboard::draw(float x, float y, float scale){
img.draw(x-(anchorPoint.x*scale),y-(anchorPoint.y*scale),img.getWidth()*scale,img.getHeight()*scale);
}
-void Tag::play(){
+void Tag::play(int time){
isPlaying=true;
- startTime=ofGetElapsedTimeMillis();
+ startTime=ofGetElapsedTimeMillis()+time;
}
-void Tag::1playEnd(){
+void Tag::playEnd(){
end=true;
play();
}
void Tag::draw(float x, float y, float scale) {
- float time=((float)ofGetElapsedTimeMillis()-startTime)/duration;
- float yshift=0.0f;
- if (end) {
- if (time<1.0) yshift=pow((time),0.7)-1.0;
+ if (ofGetElapsedTimeMillis()>=startTime) {
+ float time=((float)ofGetElapsedTimeMillis()-startTime)/duration;
+ float yshift=0.0f;
+ if (end) {
+ if (time<1.0) yshift=pow((time),0.7)-1.0;
+ }
+ else {
+ if (time<0.4) yshift=pow((time/0.4),0.7)-1.0;
+ else if (time>0.75) yshift=-pow((time-0.75)/0.25,0.75);
+ if ((ofGetElapsedTimeMillis()-startTime)>duration) isPlaying=false;
+ }
+ img.draw(x-(anchorPoint.x*scale),y-(anchorPoint.y*scale)+(yshift*img.getHeight()*scale),img.getWidth()*scale,img.getHeight()*scale);
}
- else {
- if (time<0.4) yshift=pow((time/0.4),0.7)-1.0;
- else if (time>0.75) yshift=-pow((time-0.75)/0.25,0.75);
- if ((ofGetElapsedTimeMillis()-startTime)>duration) isPlaying=false;
- }
- img.draw(x-(anchorPoint.x*scale),y-(anchorPoint.y*scale)+(yshift*img.getHeight()*scale),img.getWidth()*scale,img.getHeight()*scale);
}
diff --git a/vfg/src/Tag.h b/vfg/src/Tag.h index 1648136..7174872 100755 --- a/vfg/src/Tag.h +++ b/vfg/src/Tag.h @@ -24,7 +24,7 @@ class Tag: public Billboard { public:
Tag(string name,int d,float xPct=0.5f,float yPct=0.5f): Billboard(name,xPct,yPct) {duration =d; end=false; };
void draw(float x, float y, float scale=1.0f);
- void play();
+ void play(int time=0);
void playEnd();
bool isPlaying;
protected:
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index 4e5e576..2a95571 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -198,9 +198,10 @@ void testApp::update(){ activatePractice(); } else if (ret==ASTERISK_GAMEOVER) { - printf("player hung up!\n"); - songs[currentsong]->gameOver(); - endGame(); + if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE||gamestate==GAME_PRACTICE2) { + printf("player hung up!\n"); + endGame(); + } } else if (ret>48&&ret<52) { songs[currentsong]->playerControl(ret-49); @@ -212,6 +213,11 @@ void testApp::update(){ practiceSong.playerControl(ret-52); (*playanimal)[ret-52].playNow("Clap"); } + else if (ret>54&&ret<58) { + songs[currentsong]->playerControl(ret-55); + practiceSong.playerControl(ret-55); + (*playanimal)[ret-55].playNow("Clap"); + } if (songs[currentsong]->isPlaying&&songs[currentsong]->getLevel(ofGetElapsedTimeMillis()+4000)>currentlevel) { int anim=ofRandom(1.9999); //this gives a binary random number for (int i=0;i<3;i++) { @@ -230,13 +236,13 @@ void testApp::update(){ case GAME_ENDPLAYING: case GAME_ENDINGINTRO: case GAME_PRACTICE: + case GAME_PRACTICE2: case GAME_WALKON: background.update(); banner.update(); wirebirds.update(); break; case GAME_STARTINGINTRO: - background.update(); case GAME_INTRO: intro.update(); break; @@ -247,6 +253,9 @@ void testApp::update(){ case GAME_ADVERT: advert.update(); break; + case GAME_ENDTITLE: + background.update(); + break; } } @@ -299,6 +308,7 @@ void testApp::draw(){ switch(gamestate) { case GAME_STARTINGINTRO: case GAME_INTRO: + ofDisableAlphaBlending(); intro.draw(hOffs,0,ofGetHeight(),ofGetHeight()); break; case GAME_ENDINGINTRO: @@ -310,6 +320,7 @@ void testApp::draw(){ case GAME_ENDPLAYING: case GAME_WALKON: case GAME_ENDTITLE: + ofDisableAlphaBlending(); drawBackgroundLayers(); break; case GAME_STARTINGADVERT: @@ -347,8 +358,10 @@ void testApp::draw(){ } } aspect=advert.getHeight()/advert.getWidth(); - wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5; - advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect); + float maxwidth=min((float)ofGetWidth(),ofGetHeight()*1.2f); + float wstart=(ofGetWidth()-maxwidth)*0.5; + wOffs=(ofGetHeight()-(maxwidth*aspect))*0.5; + advert.draw(wstart,wOffs,maxwidth,maxwidth*aspect); ofDisableAlphaBlending(); //may have been turned on during intro break; @@ -443,8 +456,8 @@ void testApp::draw(){ } else break; case GAME_ENDTITLE: - //DCC LOGO - logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); + //DCC LOGO FOR DUBLIN + //logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale); case GAME_ENDINGINTRO: case GAME_READY: case GAME_STARTPLAYING: @@ -465,11 +478,13 @@ void testApp::draw(){ //draw banner and wirebirds bannerscale=scale; ofSetColor(255,255,255); + float birdoffset; switch(gamestate) { 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()*birdpoint,scale); + birdoffset=-((1.0f-(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.0003,1.0))))*ofGetWidth()); + wirebirds.draw(birdoffset+(ofGetWidth()/2),ofGetHeight()*birdpoint,scale); segamt=1.0; ofEnableAlphaBlending(); banner.draw(ofGetWidth()*0.5,0,bannerscale); @@ -494,19 +509,17 @@ void testApp::draw(){ case GAME_PRACTICE2: case GAME_STARTPLAYING: case GAME_PLAYING: - 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: - bannerscale=scale*0.675; ofEnableAlphaBlending(); + if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale); + bannerscale=scale*0.675; banner.draw(ofGetWidth()*0.5,0,bannerscale); break; case GAME_WALKON: - bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); ofEnableAlphaBlending(); + bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325)); + birdoffset=(((max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.0003,1.0))))*ofGetWidth()); + if (showWire) wirebirds.draw(birdoffset+(ofGetWidth()/2),ofGetHeight()*birdpoint,scale); banner.draw(ofGetWidth()*0.5,0,bannerscale); break; } @@ -565,6 +578,7 @@ void testApp::draw(){ case GAME_PLAYING: backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0))); if (songs[currentsong]->isGameover()) { + hangUp(); endGame(); } break; @@ -660,11 +674,11 @@ void testApp::queueWalkOn(){ (*playanimal)[i].clear(); int numcycles,start; if (playanimal==&penguins) { - start=400; //(of 700 cycle) + start=600; //(of 700 cycle) was 400 numcycles=7; } else { - start=400; //of 780 + start=200; //of 780 was 400 numcycles=5; } (*playanimal)[i].play("Walking",ofGetElapsedTimeMillis()+start); @@ -672,15 +686,25 @@ void testApp::queueWalkOn(){ (*playanimal)[i].play("Walk_end"); } } -void testApp::endGame(){ +void testApp::hangUp(){ 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); +} +void testApp::endGame(){ + switch (gamestate) { + case GAME_PRACTICE: + case GAME_PRACTICE2: + practiceSong.gameOver(); + break; + case GAME_PLAYING: + songs[currentsong]->gameOver(); + break; + } gamestate=GAME_ENDPLAYING; - tags[6]->play(); + tags[6]->play(1000); segmentStartTime=ofGetElapsedTimeMillis(); - queueWalkOff(); } //-------------------------------------------------------------- @@ -709,7 +733,8 @@ void testApp::keyPressed(int key){ } break; case 'e': - if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE) { + if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE||gamestate==GAME_PRACTICE2) { + hangUp(); endGame(); } break; diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index 2838483..14a0fbf 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -81,6 +81,7 @@ class testApp : public ofxFensterListener{ void activatePractice(); void switchAnimals(); void endGame(); + void hangUp(); void queueWalkOff(); void queueWalkOn(); |
