From 75c277c10f206f5bf3799caa03a52f40c1c8b6cf Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 27 Nov 2012 15:45:35 +0000 Subject: characters reacting to level ends --- vfg/bin/data/Levels_DeckTheHalls.4.0.xml | 7 + vfg/bin/data/Levels_JingleBells.4.0.xml | 7 + vfg/bin/data/Lyrics_DeckTheHalls.4.0.xml | 70 +++++ vfg/bin/data/Lyrics_JingleBells.4.0.xml | 44 ++++ vfg/bin/data/VODA_MUS_JingleBells_MIDI_v.4.0.xml | 321 +++++++++++++++++++++++ vfg/src/Asterisk.cpp | 2 +- vfg/src/music.cpp | 21 +- vfg/src/music.h | 23 +- vfg/src/testApp.cpp | 46 +++- vfg/src/testApp.h | 9 +- vpn/notes.txt | 3 +- 11 files changed, 521 insertions(+), 32 deletions(-) create mode 100755 vfg/bin/data/Levels_DeckTheHalls.4.0.xml create mode 100755 vfg/bin/data/Levels_JingleBells.4.0.xml create mode 100755 vfg/bin/data/Lyrics_DeckTheHalls.4.0.xml create mode 100755 vfg/bin/data/Lyrics_JingleBells.4.0.xml create mode 100755 vfg/bin/data/VODA_MUS_JingleBells_MIDI_v.4.0.xml diff --git a/vfg/bin/data/Levels_DeckTheHalls.4.0.xml b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml new file mode 100755 index 0000000..6719801 --- /dev/null +++ b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/vfg/bin/data/Levels_JingleBells.4.0.xml b/vfg/bin/data/Levels_JingleBells.4.0.xml new file mode 100755 index 0000000..9b8ef79 --- /dev/null +++ b/vfg/bin/data/Levels_JingleBells.4.0.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/vfg/bin/data/Lyrics_DeckTheHalls.4.0.xml b/vfg/bin/data/Lyrics_DeckTheHalls.4.0.xml new file mode 100755 index 0000000..67e35c7 --- /dev/null +++ b/vfg/bin/data/Lyrics_DeckTheHalls.4.0.xml @@ -0,0 +1,70 @@ + + + Deck the halls + with boughs + of holly + Fa-la + la-la-la + la-la-la-la + 'tis the season + to be jolly + Fa-la + la-la-la + la-la-la-la + Don we now + our gay apparel + Fa-la-la + la-la-la + la-la-la + Troll the ancient + yule-tide + carol + Fa-la + la-la-la + la-la-la-la + + See the blazing + Yule before us + Fa-la + la-la-la + la-la-la-la + Strike the harp + and join + the chorus + Fa-la + la-la-la + la-la-la-la + Follow me + in merry measure + Fa-la-la + la-la-la + la-la-la + While I tell of + Yule-tide treasure + Fa-la + la-la-la + la-la-la-la + + Deck the halls + with boughs + of holly + Fa-la + la-la-la + la-la-la-la + 'tis the season + to be jolly + Fa-la + la-la-la + la-la-la-la + Don we now + our gay apparel + Fa-la-la + la-la-la + la-la-la + Troll the ancient + yule-tide + carol + Fa-la + la-la-la + la-la-la-la + diff --git a/vfg/bin/data/Lyrics_JingleBells.4.0.xml b/vfg/bin/data/Lyrics_JingleBells.4.0.xml new file mode 100755 index 0000000..a5cce7d --- /dev/null +++ b/vfg/bin/data/Lyrics_JingleBells.4.0.xml @@ -0,0 +1,44 @@ + + + Jingle bells + jingle bells + jingle all the way + Oh, what fun + it is to ride + On a one horse + open sleigh-O + + Jingle bells + jingle bells + jingle all the way + Oh, what fun + it is to ride + On a one horse + open sleigh + + Dashing through the snow + on a one horse open sleigh + O'er the fields we go + laughing all the way + Bells on bobtails ring + making spirits bright + What fun it is to laugh and sing + a sleighing song tonight + + Jingle bells + jingle bells + jingle all the way + Oh, what fun + it is to ride + On a one horse + open sleigh-O + + Jingle bells + jingle bells + jingle all the way + Oh, what fun + it is to ride + On a one horse + open sleigh + + diff --git a/vfg/bin/data/VODA_MUS_JingleBells_MIDI_v.4.0.xml b/vfg/bin/data/VODA_MUS_JingleBells_MIDI_v.4.0.xml new file mode 100755 index 0000000..697b638 --- /dev/null +++ b/vfg/bin/data/VODA_MUS_JingleBells_MIDI_v.4.0.xml @@ -0,0 +1,321 @@ + + + + Melody + Melody + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp index 8a2309e..5392ade 100755 --- a/vfg/src/Asterisk.cpp +++ b/vfg/src/Asterisk.cpp @@ -47,7 +47,7 @@ int Asterisk::update(){ udpConnection.Receive(udpMessage,10000); string msg=udpMessage; if(msg!=""){ - if (msg.length()>2) { + if (msg.length()>3) { //printf("status msg: %s\n",msg.c_str()); if (msg.substr(0,5)=="Local") { state=PLAYING; diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 359b21d..b5b584c 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -28,7 +28,7 @@ void lyricscore::draw(){ } //---------------------------------------------------------------------------------------------------------- musicscore::musicscore() { - timeframe=2000; + timeframe=5000; missedLast=false; nowpoint=1.0f; missedNote=-1; @@ -124,7 +124,7 @@ void musicscore::parseMidi(string filename){ iter1--; printf("processed %s: length %f, %i notes in %f seconds\n",filename.c_str(),((float)(iter1->first+iter1->second->duration)*.001f),notes.size(),ofGetElapsedTimef()-wt); } -void musicscore::makeFlakes(int threshStart,int threshEnd){ +void musicscore::makeFlakes(int threshStart,int threshEnd,levelscore *levels){ flakes.clear(); //decimate notes to generate flakes that can be interacted with map::iterator iter; @@ -137,12 +137,12 @@ void musicscore::makeFlakes(int threshStart,int threshEnd){ flakes[notes.begin()->first]->puppet=snowflakes[notemap(lastNote->num)]; for (iter = notes.begin(); iter != notes.end(); iter++) { float songPos=((float)iter->first)/songDuration; - if ((notemap(iter->second->num)!=notemap(lastNote->num))||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart)))) { + if ((levels->nextLevelTime(iter->first)>2000)&&((notemap(iter->second->num)!=notemap(lastNote->num))||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart))))) { flakes[iter->first]=new flake(iter->second->num,iter->second->velocity,iter->second->duration); flakes[iter->first]->puppet=snowflakes[notemap(iter->second->num)]; + lastNote=iter->second; + lastTime=iter->first; } - lastNote=iter->second; - lastTime=iter->first; } missedFlake=flakes.end(); missedNote=-1; @@ -210,7 +210,7 @@ void musicscore::drawFlakes(levelscore *levels) { } missedLast=!iter->second->activated; } - //at this point missed points to the latest unactivated flake in the level + //at this point missed points to the latest unactivated flake in the level if there is one if ((missed!=flakes.end())&&(missedFlake!=missed)) { missedFlake=missed; missedNote=notemap(missed->second->num); @@ -237,7 +237,7 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string lyrics.load(lyricfile); levels.load(levelfile); isPlaying=false; - keyThresh=400; + keyThresh=500; notes.setNowpoint(0.8f); } void song::setTimeframe(int millis) {notes.setTimeframe(millis);} @@ -253,7 +253,7 @@ void song::play() { notes.start(); lyrics.start(); isPlaying=true; - notes.makeFlakes(fThreshStart,fThreshEnd); + notes.makeFlakes(fThreshStart,fThreshEnd,&levels); } void song::stop() { backing.stop(); @@ -266,7 +266,7 @@ void song::preRoll(long preroll) { lyrics.start(startTime); isPreroll=true; isPlaying=true; - notes.makeFlakes(fThreshStart,fThreshEnd); + notes.makeFlakes(fThreshStart,fThreshEnd,&levels); } void song::drawNotes(){ notes.drawNotes(&levels); @@ -307,4 +307,7 @@ int song::hitNote(){ int n=notes.hitNote; notes.hitNote=-1; return n; +} +int song::getLevel(long time){ + return levels.getLevel(time-startTime); } diff --git a/vfg/src/music.h b/vfg/src/music.h index 7e54292..1cb92ff 100755 --- a/vfg/src/music.h +++ b/vfg/src/music.h @@ -17,14 +17,22 @@ class levelscore { if( !XML.loadFile(filename) ){ printf("unable to load %s check data/ folder\n",filename.c_str()); }else{ + int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0); if(XML.pushTag("VFxmas")) { for (int i=0;i::iterator iter=levels.end(); + iter--; + for (int i=0;ifirst;i+=500) { + printf("time %i: level %i, nextleveltime %i\n",i,getLevel(i), nextLevelTime(i)); + } + } int getLives(int time) { map::iterator iter; int lives=0; @@ -52,6 +60,14 @@ class levelscore { } return bound; } + int nextLevelTime(int time) { + map::iterator iter; + int level=-1; + for (iter = levels.begin(); iter != levels.end(); ++iter) { + if (iter->first>time) return iter->first-time; + } + return 2<<20; // a big number + } private: map levels; }; @@ -115,7 +131,7 @@ class lyricscore: public score { if( !XML.loadFile(filename) ){ printf("unable to load %s check data/ folder\n",filename.c_str()); }else{ - int multiplier=1000/XML.getAttribute("VFxmas", "timebase",0,0); + int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0); if(XML.pushTag("VFxmas")) { for (int i=0;isetTimeframe(2500); + //testsong=new song("VODA_MUS_DeckTheHalls-Backing_v.1.5.mp3","VODA_MUS_DeckTheHalls-Melody_v.1.5.mp3","MIDI_DeckTheHalls_MIDI.1.5.xml","Lyrics_DeckTheHalls.1.5.xml","Levels_DeckTheHalls.1.5.xml"); + testsong=new song("JingleBells_v.4.0/VODA_MUS_JingleBells_Backing_v.4.0.mp3","JingleBells_v.4.0/VODA_MUS_JingleBells_Melody_v.4.0.mp3","VODA_MUS_JingleBells_MIDI_v.4.0.xml","Lyrics_JingleBells.4.0.xml","Levels_JingleBells.4.0.xml"); + + testsong->setTimeframe(3000); testsong->setFlakeThresh(1000,100); ofSetBackgroundAuto(false); ofBackground(0,0,0); - /* + for (int i=0;i<3;i++) penguins.push_back(Animal()); penguins[0].load("Penguin-Blue.xml"); penguins[1].load("Penguin-Purple.xml"); penguins[2].load("Penguin-Green.xml"); - for (int i=0;i<3;i++) raccoons.push_back(Animal()); + for (int i=0;i<3;i++) raccoons.push_back(Animal()); raccoons[0].load("Raccoon-Blue.xml"); raccoons[1].load("Raccoon-Purple.xml"); raccoons[2].load("Raccoon-Green.xml"); - */ - loadanimals("Raccoons"); - playanimal =&playanimals; + + //loadanimals("Raccoons"); + playanimal =&penguins; //testpenguin.load("Penguin-Blue.xml"); //debug: commented out: 436m 257m @@ -41,8 +43,9 @@ void testApp::setup(){ showFPS=false; -} +} +/* void testApp::loadanimals(string which) { playanimals.clear(); @@ -60,6 +63,7 @@ void testApp::loadanimals(string which) { } } +*/ void testApp::exit(){ delete testsong; @@ -69,11 +73,22 @@ void testApp::exit(){ void testApp::update(){ int ret=game.update(); if (ret==1000) { + currentlevel=0; testsong->preRoll(250); } - else if (ret>0) { - testsong->playerControl(ret); - (*playanimal)[ret-1].playNow("Clap"); + else if (ret>48&&ret<52) { + testsong->playerControl(ret-48); + (*playanimal)[ret-49].playNow("Clap"); + } + if (testsong->isPlaying&&testsong->getLevel(ofGetElapsedTimeMillis()+2000)>currentlevel) { + int anim=ofRandom(1.9999); //this gives a binary random number + for (int i=0;i<3;i++) { + if (anim) (*playanimal)[i].playNow("Happy"); + else (*playanimal)[i].playNow("Jump"); + anim=(anim+1)%2; + } + //printf("finished level %i!\n",currentlevel); + currentlevel++; } for (int i=0;i<3;i++) { (*playanimal)[i].update(); @@ -121,6 +136,7 @@ void testApp::keyPressed(int key){ switch (key) { case ' ': if (!testsong->isPlaying) { + currentlevel=0; testsong->preRoll(250); } break; @@ -137,10 +153,12 @@ void testApp::keyPressed(int key){ showFPS=!showFPS; break; case 'r': - loadanimals("Raccoons"); + //loadanimals("Raccoons"); + playanimal =&raccoons; break; case 'p': - loadanimals("Penguins"); + //loadanimals("Penguins"); + playanimal =&penguins; break; } diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index 4ab807f..2518b55 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -73,23 +73,24 @@ class testApp : public ofBaseApp{ void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); - void loadanimals(string which); + //void loadanimals(string which); ofVideoPlayer background; ofImage vignette; song *testsong; - /* + vector penguins; vector raccoons; - */ - vector playanimals; + + //vector playanimals; vector* playanimal; Puppet testpenguin; + int currentlevel; Asterisk game; diff --git a/vpn/notes.txt b/vpn/notes.txt index 04e07a3..6cb0e6c 100755 --- a/vpn/notes.txt +++ b/vpn/notes.txt @@ -1,5 +1,6 @@ sudo openvpn --config server.conf 01-5548000 +1800-804444 ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME passcode 89889"' ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "database put GAME ip 4.4.4.4"' -ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "devstate change Custom:GAME NOT_INUSE"' \ No newline at end of file +ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx "devstate change Custom:GAME NOT_INUSE"' -- cgit v1.2.3