summaryrefslogtreecommitdiff
path: root/vfg/src
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src')
-rwxr-xr-xvfg/src/Asterisk.cpp97
-rwxr-xr-xvfg/src/Asterisk.h14
-rwxr-xr-xvfg/src/Puppet.cpp33
-rwxr-xr-xvfg/src/Puppet.h15
-rwxr-xr-xvfg/src/music.cpp49
-rwxr-xr-xvfg/src/music.h7
-rwxr-xr-xvfg/src/testApp.cpp110
-rwxr-xr-xvfg/src/testApp.h2
8 files changed, 220 insertions, 107 deletions
diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp
index 98ffd9d..55a77e0 100755
--- a/vfg/src/Asterisk.cpp
+++ b/vfg/src/Asterisk.cpp
@@ -33,25 +33,28 @@ gameQ has 1 calls (max unlimited) in 'rrmemory' strategy (8s holdtime, 50s talkt
void Asterisk::threadedFunction(){
- while( isThreadRunning() != 0 ){
- FILE *f = popen("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"queue show gameQ\"'", "re");
- int fn=fileno(f);
- char buf[1000];
- ssize_t r = read(fn, buf, 1000);
- pclose(f);
- string msg=string(buf);
- //received data is always a command ACKNOWLEDGEMENT
- if (msg.compare(0,5,"gameQ")==0) {
- vector<std::string> lines;
- split(msg,'\n',lines);
- queued=0;
- for (int i=4;i<lines.size();i++) {
- if (lines[i].compare(0,6," ")==0&&lines[i].compare(7,1,".")==0) queued++;
- }
- }
- else {
- printf("status err: %s\n",buf);
- }
+ while( isThreadRunning() != 0 ){
+ //if (lock()) {
+ 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];
+ ssize_t r = read(fn, buf, 1000);
+ pclose(f);
+ string msg=string(buf);
+ //received data is always a command ACKNOWLEDGEMENT
+ if (msg.compare(0,5,"gameQ")==0) {
+ vector<std::string> lines;
+ split(msg,'\n',lines);
+ queued=0;
+ for (int i=4;i<lines.size();i++) {
+ if (lines[i].compare(0,6," ")==0&&lines[i].compare(7,1,".")==0) queued++;
+ }
+ }
+ else {
+ printf("status err: %s\n",buf);
+ }
+ //unlock();
+ //}
ofSleepMillis(statusPollMillis);
}
@@ -64,42 +67,68 @@ void Asterisk::setup(string passcode,int millis){
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(true, false); // blocking, verbose
+ if (statusPollMillis>0) startThread(false, false); // blocking, verbose
}
-void Asterisk::startGame(){
- if (state==ASTERISK_IDLE&&queued) {
- cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"devstate change Custom:GAME NOT_INUSE\"'");
- printf("Asterisk: attempting to dequeue\n");
- state=ASTERISK_WAITING;
- }
+void Asterisk::startGame(){
+ //if (lock()) {
+ if (state==ASTERISK_IDLE&&queued) {
+ cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"devstate change Custom:GAME NOT_INUSE\"'");
+ printf("Asterisk: attempting to dequeue\n");
+ }
+ //unlock();
+ //}
}
void Asterisk::endGame(string score){
printf("Asterisk: request hangup %s\n",playerCode.c_str());
if (state==ASTERISK_PLAYING) {
- cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME statuscode "+score+"\"'");
+ //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+"\"'";
- cmd(emsg);
+ scmd(emsg);
printf("Asterisk: hanging up %s\n",playerCode.c_str());
state=ASTERISK_IDLE;
}
}
void Asterisk::cmd(string s) {
- //non blocking command for anync messages
- file = popen(s.c_str(), "re");
+ //non blocking command for anync messages
+ //pclose(file); always closing before open crashes
+ //printf("open file\n");
+ 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);
-}
+ fcntl(filenum, F_SETFL, O_NONBLOCK);
+ state=ASTERISK_WAITING;
+}
+
+void Asterisk::scmd(string s) {
+ //non blocking command for anync messages
+ //pclose(file); always closing before open crashes
+ //printf("open file\n");
+ 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);
+ //printf("close file\n");
+ pclose(file);
+}
+
+
+/*Child process PID: 4265
+Program received signal SIGABRT, Aborted.
+In __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64 ()
+Cannot open file: /home/tim/workspace/VFxmas/vfg/iofclose.c
+*/
+
int Asterisk::update(){
//capture stdin response from popen
- if (state==ASTERISK_WAITING||state==ASTERISK_STARTING) {
+ if (state==ASTERISK_WAITING) {
char buf[100];
ssize_t r = read(filenum, buf, 1000);
//if (r == -1 && errno == EAGAIN)
//no data yet
//else
- if (r > 0) {
+ if (r > 0) {
+ //is it here?
+ //printf("close file\n");
pclose(file);
string msg=string(buf);
state=ASTERISK_IDLE;
diff --git a/vfg/src/Asterisk.h b/vfg/src/Asterisk.h
index 8093213..fb6097c 100755
--- a/vfg/src/Asterisk.h
+++ b/vfg/src/Asterisk.h
@@ -17,16 +17,16 @@ class Asterisk: public ofThread
public:
Asterisk(){
}
-
+
void start(){
-
+
}
void stop(){
stopThread();
}
//--------------------------
-
+
void setup(string passcode="1111",int millis=1000);
virtual ~Asterisk();
void startGame();
@@ -36,7 +36,8 @@ class Asterisk: public ofThread
int queued;
protected:
- void cmd(string s);
+ void cmd(string s);
+ void scmd(string s);
void threadedFunction();
private:
int startTime;
@@ -44,8 +45,9 @@ class Asterisk: public ofThread
int filenum;
ofxUDPManager udpConnection;
string playerCode;
- int statusPollMillis;
-
+ int statusPollMillis;
+
+
};
#endif // ASTERISK_H
diff --git a/vfg/src/Puppet.cpp b/vfg/src/Puppet.cpp
index 90ba137..9d9a11e 100755
--- a/vfg/src/Puppet.cpp
+++ b/vfg/src/Puppet.cpp
@@ -36,38 +36,45 @@ void Puppet::load(string filename) {
void Puppet::draw(float x, float y, float scale) {
if (playlist.size()>0) {
- if (!clips[playlist[0]].getIsPlaying()) {
- playlist.erase(playlist.begin());
- if (playlist.size()>0) {
- clips[playlist[0]].play();
+ if (!clips[playlist[0].second].getIsPlaying()) {
+ if (ofGetElapsedTimeMillis()-playlist[0].first>clips[playlist[0].second].getDuration()) {
+ playlist.erase(playlist.begin());
+ }
+ if (playlist.size()>0) {
+ if (playlist[0].first<ofGetElapsedTimeMillis())
+ clips[playlist[0].second].play();
}
}
}
if (playlist.size()==0) {
if (clips.find("base") != clips.end()) clips["base"].draw(x,y,scale);
}
- else {
- clips[playlist[0]].update();
- clips[playlist[0]].draw(x,y,scale);
+ else if (clips[playlist[0].second].getIsPlaying()){
+ clips[playlist[0].second].update();
+ clips[playlist[0].second].draw(x,y,scale);
}
}
-void Puppet::play(string clip){
+void Puppet::play(string clip,int time){
if (clips.find(clip) != clips.end()) {
- playlist.push_back(clip);
- if (playlist.size()==1) clips[playlist[0]].play();
+ playlist.push_back(make_pair(time,clip));
+ if (playlist.size()==1&&time<ofGetElapsedTimeMillis()) clips[playlist[0].second].play();
//printf("playing %s, %i, %s\n",playlist[0].c_str(),playlist.size(),clips[playlist[0]].getIsPlaying()?"true":"false");
}
}
-void Puppet::playNow(string clip){
+void Puppet::playNow(string clip,int time){
if (playlist.size()>0) {
- clips[playlist[0]].stop();
+ clips[playlist[0].second].stop();
playlist.clear();
}
play(clip);
}
bool Puppet::isPlaying(){
- if (playlist.size()>0) return clips[playlist[0]].getIsPlaying();
+ if (playlist.size()>0) return clips[playlist[0].second].getIsPlaying();
else return false;
}
+
+void Puppet::clear(){
+ playlist.clear();
+}
diff --git a/vfg/src/Puppet.h b/vfg/src/Puppet.h
index 1f6d90a..d685a76 100755
--- a/vfg/src/Puppet.h
+++ b/vfg/src/Puppet.h
@@ -19,6 +19,9 @@ class puppetSprite: public ofxSprite {
public:
void draw(float x, float y, float scale) {
getCurrentImage().draw(x-(anchorPoint.x*scale),y-(anchorPoint.y*scale),getWidth()*scale,getHeight()*scale);
+ }
+ int getDuration() {
+ return totalFrames*(1000/frameRate);
}
};
@@ -28,14 +31,18 @@ class Puppet
Puppet();
virtual ~Puppet();
void load(string filename);
- void play(string clip);
- void playNow(string clip);
+ void play(string clip,int time=0);
+ void playNow(string clip,int time=0);
void draw(float x, float y, float scale=1.0f);
- bool isPlaying();
+ bool isPlaying();
+ void clear();
protected:
private:
map<string,puppetSprite> clips;
- deque<string> playlist;
+ //deque<string> playlist;
+ deque< pair<int,string> > playlist; //time,clip = when it comes to play, pause until time, or just leave at 0 to play immediate
+ //time absolute
+ //need a clear method? should never be called really
};
#endif // PUPPET_H
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index c920a02..4cddab9 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -213,8 +213,8 @@ void musicscore::drawFlakes(float hOffs,levelscore *levels,float scale) {
//else ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
//if (iter->second->activated&&(!iter->second->disintegrated)) iter->second->disintegrate();
+ //ofSetColor(255,255,255); //allow external fading
- ofSetColor(255,255,255);
iter->second->draw((gridX[notemap(iter->second->num)+1]*ofGetHeight())+hOffs,ofGetHeight()-(thisstart*heightStep),scale);
//todo - make all drawing resolution independent
@@ -269,7 +269,8 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string
lyrics.load(lyricfile);
levels.load(levelfile);
isPlaying=false;
- isPractice=false;
+ isPractice=false;
+ fademillis=1000;
}
void song::setTimeframe(int millis) {notes.setTimeframe(millis);}
void song::setKeyThresh(int millis) {notes.keyThresh=millis;}
@@ -286,7 +287,8 @@ void song::play() {
void song::stop() {
backing.stop();
melody.stop();
- isPlaying=false;
+ isPlaying=false;
+ printf("stoppping song: %i (%i)\n",ofGetElapsedTimeMillis()-startTime,levels.length);
}
void song::preRoll(long preroll) {
startTime=ofGetElapsedTimeMillis()+preroll;
@@ -318,12 +320,18 @@ int song::getLength(){
}
bool song::isGameover(){
return gameover;
+}
+void song::gameOver(){
+
+ gameover=true;
+ gameoverTime=ofGetElapsedTimeMillis();
}
bool song::isFinished(){
return (ofGetElapsedTimeMillis()-startTime>=levels.length);
}
void song::draw(float hOffs,float scale){
- int songTime=ofGetElapsedTimeMillis()-startTime;
+ int songTime=ofGetElapsedTimeMillis()-startTime;
+ int fadeout=(gameover?max(0,255-((int)((((float)ofGetElapsedTimeMillis()-gameoverTime)/fademillis)*255))):255);
if (isPlaying) {
if (isPreroll&&(!isPractice)) {
if (startTime<ofGetElapsedTimeMillis()) {
@@ -331,29 +339,36 @@ void song::draw(float hOffs,float scale){
melody.play();
isPreroll=false;
}
- }
+ }
+ ofSetColor(255,255,255,fadeout);
notes.drawFlakes(hOffs,&levels,scale);
if (notes.missedLast) {
melody.setVolume(0.0f);
if (levels.getLives(songTime)) {
- if (notes.missedFlakes>levels.getLives(songTime)) {
+ if (notes.missedFlakes>levels.getLives(songTime)&&!gameover) {
//work out score
- //stop();
- gameover=true;
+ //stop();
+ printf("game over! %i (%i)\n",songTime,levels.length);
+ gameOver();
}
}
}
- else melody.setVolume(1.0f);
- if (!isPractice) lyrics.draw(hOffs);
- if (songTime>levels.length) {
- printf("stopping: %i (%i)\n",songTime,levels.length);
+ if (!notes.missedLast&&!gameover) melody.setVolume(1.0f);
+ if (!isPractice&&!gameover) lyrics.draw(hOffs);
+ if (songTime>levels.length&&!gameover) {
+ printf("finished! %i (%i)\n",songTime,levels.length);
+ //this played loads of times
//stop();
- gameover=true;
- }
- }
- else {
- //fade out song + melody :: clean up
+ gameOver();
+ }
+ ofSetColor(255,255,255);
+ if (gameover) {
+ melody.setVolume(notes.missedLast?0.0f:((float)fadeout)/255.0f);
+ backing.setVolume(((float)fadeout)/255.0f);
+ if (fadeout==0) stop();
+ }
}
+
}
void song::playerControl(int key){
notes.playerControl(key);
diff --git a/vfg/src/music.h b/vfg/src/music.h
index 60a35f2..c4a26ca 100755
--- a/vfg/src/music.h
+++ b/vfg/src/music.h
@@ -210,7 +210,8 @@ class song {
string getScoreString();
string getName();
int getLength();
- bool isGameover();
+ bool isGameover();
+ void gameOver();
bool isFinished();
bool gameover;
@@ -221,10 +222,10 @@ class song {
lyricscore lyrics;
levelscore levels;
- int startTime;
+ int startTime,gameoverTime;
bool isPreroll,isPractice;
- int fThreshStart,fThreshEnd;
+ int fThreshStart,fThreshEnd,fademillis;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
/*
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 8c701b2..3e711f2 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -16,11 +16,23 @@ void guiWindow::draw(){
parent->gui.draw();
ofSetColor(255,255,255);
ofDrawBitmapString(ofToString(parent->game.queued)+" in queue", 10,ofGetHeight()-15);
- char buf[8];
+ char buf[200];
sprintf(buf,"%.1f",ofGetFrameRate());
ofDrawBitmapString(buf, ofGetWidth()-43,ofGetHeight()-15);
ofDrawBitmapString(levelnames[parent->gamestate-1], 10,ofGetHeight()-35);
- if (parent->gamestate==GAME_PLAYING) ofDrawBitmapString(parent->songs[parent->currentsong]->getScoreString(),10,ofGetHeight()-55);
+ switch (parent->gamestate) {
+ case GAME_PLAYING:
+ ofDrawBitmapString(parent->songs[parent->currentsong]->getScoreString(),10,ofGetHeight()-55);
+ break;
+ case GAME_INTRO:
+ sprintf(buf,"%f %i of %i",parent->intro.getPosition(),parent->intro.getCurrentFrame(),parent->intro.getTotalNumFrames());
+ ofDrawBitmapString(buf,10,ofGetHeight()-55);
+ break;
+ case GAME_ADVERT:
+ sprintf(buf,"%f %i of %i",parent->advert.getPosition(),parent->advert.getCurrentFrame(),parent->advert.getTotalNumFrames());
+ ofDrawBitmapString(buf,10,ofGetHeight()-55);
+ break;
+ }
}
void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){
@@ -35,6 +47,9 @@ void testApp::setup(){
game.setup("1122",2000); //Asterisk.cpp thread polls server every 2000ms
+//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("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"));
@@ -74,7 +89,7 @@ void testApp::setup(){
lyricspanel=new Billboard("Lyrics-panel.png",0.5,0.703);
- banner.load("Ribbon/Dublin/Ribbon-Dublin_%05i.png",500);
+ banner.load("Ribbon/Dublin/Ribbon_%05i.png",500);
banner.setAnchorPercent(0.5,0.0);
banner.setFrameRate(50);
banner.play();
@@ -98,11 +113,11 @@ void testApp::setup(){
//mount -t tmpfs -o size=64M tmpfs /RAM
//cp *.m* RAM
- intro.loadMovie("RAM/Game-Demo_v5.mp4");
+ intro.loadMovie("RAM/Game-Demo_v6_DUBLIN.mp4");
intro.setLoopState(OF_LOOP_NONE);
intro.setVolume(0.0);
- advert.loadMovie("RAM/GW2003761_GRY-VFBR055-060_MPEG_hi.mov");
+ advert.loadMovie("RAM/VFxmasAD.mov");
advert.setLoopState(OF_LOOP_NONE);
advert.setVolume(1.0);
@@ -182,6 +197,8 @@ void testApp::update(){
activatePractice();
}
else if (ret==ASTERISK_GAMEOVER) {
+ printf("player hung up!\n");
+ songs[currentsong]->gameOver();
endGame();
}
else if (ret>48&&ret<52) {
@@ -212,6 +229,7 @@ void testApp::update(){
case GAME_ENDPLAYING:
case GAME_ENDINGINTRO:
case GAME_PRACTICE:
+ case GAME_WALKON:
background.update();
banner.update();
wirebirds.update();
@@ -259,7 +277,7 @@ void testApp::draw(){
float hOffs=(ofGetWidth()-ofGetHeight())/2;
float scale=ofGetHeight()/1080.0f;
float bannerscale,aspect,wOffs,seg; //this old chestnut
- float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength; //same variable used in all segments
+ float segamt=min(1.0f,((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength); //same variable used in all segments
int hit,missed;
switch(gamestate) {
case GAME_STARTINGINTRO:
@@ -282,9 +300,6 @@ void testApp::draw(){
case GAME_INTRO:
case GAME_ENDINGINTRO:
intro.draw(hOffs,0,ofGetHeight(),ofGetHeight());
- if (intro.getCurrentFrame()==intro.getTotalNumFrames()) {
- gamestate=GAME_READY;
- }
break;
case GAME_READY:
case GAME_STARTPLAYING:
@@ -301,9 +316,6 @@ void testApp::draw(){
drawBackgroundLayers();
break;
}
- else if (segamt>1.0) {
- gamestate=GAME_ADVERT;
- }
else {
//if (!advert.isPlaying()) advert.play();
ofEnableAlphaBlending();
@@ -388,21 +400,21 @@ void testApp::draw(){
//penguin: 11,35,11
//raccoon: 20,39,43r
ofEnableAlphaBlending();
- seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001;
+ seg=(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)/6;
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);
- songs[currentsong]->draw(hOffs,scale);//allows the song to fade its volume out and stop playing
+ 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:
- 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 tags and logos
+ ofEnableAlphaBlending();
+ seg=(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)/6;
+ 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 tags and VF logo
switch(gamestate) {
case GAME_STARTINGADVERT:
if (segamt<0.5) {
@@ -429,7 +441,7 @@ void testApp::draw(){
}
logos[0]->draw((gridX[0]*ofGetHeight())+hOffs,0,scale);
break;
- }
+ }
//draw banner, DCC logo and wirebirds
bannerscale=scale;
ofSetColor(255,255,255);
@@ -460,12 +472,16 @@ void testApp::draw(){
break;
case GAME_STARTPLAYING:
case GAME_PLAYING:
- if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,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:
+ bannerscale=scale*0.675;
+ ofEnableAlphaBlending();
+ banner.draw(ofGetWidth()*0.5,0,bannerscale);
+ break;
case GAME_WALKON:
//DCC LOGO
logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
@@ -479,18 +495,27 @@ void testApp::draw(){
case GAME_STARTINGINTRO:
case GAME_INTRO:
case GAME_ENDINGINTRO:
+ if (intro.getCurrentFrame()==intro.getTotalNumFrames()-1) {
+ gamestate=GAME_READY;
+ }
+ break;
case GAME_READY:
break;
case GAME_STARTINGADVERT:
backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0)));
+ if (segamt==1.0) {
+ gamestate=GAME_ADVERT;
+ }
case GAME_ADVERT:
- if (advert.getCurrentFrame()==advert.getTotalNumFrames()&&gamestate==GAME_ADVERT) {
+ if (advert.getCurrentFrame()==advert.getTotalNumFrames()-1) {
gamestate=GAME_ENDINGADVERT;
segmentStartTime=ofGetElapsedTimeMillis();
}
break;
case GAME_ENDINGADVERT:
backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0));
+ if (segamt==1.0) gamestate=GAME_READY;
+ break;
case GAME_STARTPLAYING:
case GAME_PRACTICE:
break;
@@ -501,17 +526,41 @@ void testApp::draw(){
}
break;
case GAME_ENDPLAYING:
- backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0));
- if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
+ if ((((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001)>6.0) {
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");
+ }
}
break;
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;
}
}
@@ -573,7 +622,8 @@ void testApp::endGame(){
//penguins: start + 289 = 8.25
//raccoons: start + 280 = 7.17
for (int i=0;i<3;i++) {
- (*playanimal)[i].play("Walk_start");
+
+ (*playanimal)[i].playNow("Walk_start");
for (int j=0;j<9;j++) (*playanimal)[i].play("Walking");
}
}
diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h
index 4b369bf..82b25a5 100755
--- a/vfg/src/testApp.h
+++ b/vfg/src/testApp.h
@@ -34,6 +34,8 @@ break clap movements
practice mode
ramdisk for movies
+the 2nd time you play , if you 'die' it doesn't trigger 'end of game', the music keeps playing and the tags keep coming up even when state is 'ready'
+
*/
#define GAME_STARTINGINTRO 1