From 9dc429df9dbd1a5ae0f93d553ccfde7ab37a53a2 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 22 Nov 2012 11:00:03 +0000 Subject: gameplay good: up against memory limit --- vfg/bin/data/Penguin-Blue.xml | 13 +++++++ vfg/bin/data/Penguin-Green.xml | 13 +++++++ vfg/bin/data/Penguin-Purple.xml | 13 +++++++ vfg/bin/data/Raccoon-Blue.xml | 13 +++++++ vfg/bin/data/Raccoon-Green.xml | 13 +++++++ vfg/bin/data/Raccoon-Purple.xml | 13 +++++++ vfg/bin/data/Settings.xml | 6 +++ vfg/bin/data/Snowflake-Blue.xml | 5 +++ vfg/bin/data/Snowflake-Green.xml | 5 +++ vfg/bin/data/Snowflake-Purple.xml | 5 +++ vfg/bin/data/flake.png | Bin 4570 -> 0 bytes vfg/src/Puppet.cpp | 10 ++--- vfg/src/Puppet.h | 11 +++++- vfg/src/music.cpp | 23 +++++++++--- vfg/src/music.h | 10 ++++- vfg/src/testApp.cpp | 77 ++++++++++++++++++++++++++------------ vfg/src/testApp.h | 12 ++++++ vfg/vfg.cbp | 6 +++ vfg/vfg.layout | 31 ++++++++------- 19 files changed, 227 insertions(+), 52 deletions(-) create mode 100755 vfg/bin/data/Penguin-Blue.xml create mode 100755 vfg/bin/data/Penguin-Green.xml create mode 100755 vfg/bin/data/Penguin-Purple.xml create mode 100755 vfg/bin/data/Raccoon-Blue.xml create mode 100755 vfg/bin/data/Raccoon-Green.xml create mode 100755 vfg/bin/data/Raccoon-Purple.xml create mode 100755 vfg/bin/data/Settings.xml create mode 100755 vfg/bin/data/Snowflake-Blue.xml create mode 100755 vfg/bin/data/Snowflake-Green.xml create mode 100755 vfg/bin/data/Snowflake-Purple.xml delete mode 100755 vfg/bin/data/flake.png (limited to 'vfg') diff --git a/vfg/bin/data/Penguin-Blue.xml b/vfg/bin/data/Penguin-Blue.xml new file mode 100755 index 0000000..f14ca16 --- /dev/null +++ b/vfg/bin/data/Penguin-Blue.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Penguin-Green.xml b/vfg/bin/data/Penguin-Green.xml new file mode 100755 index 0000000..7d8fe2c --- /dev/null +++ b/vfg/bin/data/Penguin-Green.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Penguin-Purple.xml b/vfg/bin/data/Penguin-Purple.xml new file mode 100755 index 0000000..6f86554 --- /dev/null +++ b/vfg/bin/data/Penguin-Purple.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Raccoon-Blue.xml b/vfg/bin/data/Raccoon-Blue.xml new file mode 100755 index 0000000..9e6283d --- /dev/null +++ b/vfg/bin/data/Raccoon-Blue.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Raccoon-Green.xml b/vfg/bin/data/Raccoon-Green.xml new file mode 100755 index 0000000..cbc8775 --- /dev/null +++ b/vfg/bin/data/Raccoon-Green.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Raccoon-Purple.xml b/vfg/bin/data/Raccoon-Purple.xml new file mode 100755 index 0000000..6dde4cc --- /dev/null +++ b/vfg/bin/data/Raccoon-Purple.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/vfg/bin/data/Settings.xml b/vfg/bin/data/Settings.xml new file mode 100755 index 0000000..58dfcaa --- /dev/null +++ b/vfg/bin/data/Settings.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/vfg/bin/data/Snowflake-Blue.xml b/vfg/bin/data/Snowflake-Blue.xml new file mode 100755 index 0000000..2b637fe --- /dev/null +++ b/vfg/bin/data/Snowflake-Blue.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/vfg/bin/data/Snowflake-Green.xml b/vfg/bin/data/Snowflake-Green.xml new file mode 100755 index 0000000..dba0828 --- /dev/null +++ b/vfg/bin/data/Snowflake-Green.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/vfg/bin/data/Snowflake-Purple.xml b/vfg/bin/data/Snowflake-Purple.xml new file mode 100755 index 0000000..244e553 --- /dev/null +++ b/vfg/bin/data/Snowflake-Purple.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/vfg/bin/data/flake.png b/vfg/bin/data/flake.png deleted file mode 100755 index b609837..0000000 Binary files a/vfg/bin/data/flake.png and /dev/null differ diff --git a/vfg/src/Puppet.cpp b/vfg/src/Puppet.cpp index 0fd07a6..90ba137 100755 --- a/vfg/src/Puppet.cpp +++ b/vfg/src/Puppet.cpp @@ -21,8 +21,8 @@ void Puppet::load(string filename) { for (int i=0;i0) { if (!clips[playlist[0]].getIsPlaying()) { playlist.erase(playlist.begin()); @@ -44,11 +44,11 @@ void Puppet::draw(float x, float y) { } } if (playlist.size()==0) { - if (clips.find("base") != clips.end()) clips["base"].draw(x,y); + if (clips.find("base") != clips.end()) clips["base"].draw(x,y,scale); } else { clips[playlist[0]].update(); - clips[playlist[0]].draw(x,y); + clips[playlist[0]].draw(x,y,scale); } } diff --git a/vfg/src/Puppet.h b/vfg/src/Puppet.h index e0df87a..7ee80ee 100755 --- a/vfg/src/Puppet.h +++ b/vfg/src/Puppet.h @@ -11,6 +11,13 @@ TODO: make resolution independent */ +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); + } +}; + class Puppet { public: @@ -19,11 +26,11 @@ class Puppet void load(string filename); void play(string clip); void playNow(string clip); - void draw(float x, float y); + void draw(float x, float y, float scale=1.0f); bool isPlaying(); protected: private: - map clips; + map clips; deque playlist; }; diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index eda58be..359b21d 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -32,6 +32,7 @@ musicscore::musicscore() { missedLast=false; nowpoint=1.0f; missedNote=-1; + hitNote=-1; snowflakes.push_back(Puppet()); snowflakes.push_back(Puppet()); @@ -163,7 +164,7 @@ void musicscore::drawNotes(levelscore *levels) { int thisnote=iter->second->num-firstnote; int thisstart=iter->first-scoreStart; int thislength=iter->second->duration; - ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,100)); + ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,100),120); ofRect(thisnote*widthStep,ofGetHeight()-(thisstart*heightStep),widthStep,-(thislength*heightStep)); } @@ -172,6 +173,7 @@ void musicscore::drawFlakes(levelscore *levels) { ofEnableAlphaBlending(); int scoreStart=ofGetElapsedTimeMillis()-startTime-((1.0f-nowpoint)*timeframe); int scoreEnd=scoreStart+timeframe; + float scale=ofGetHeight()/1080.0f; //note drawing 46h - 52h int numnotes=16; int firstnote=70; @@ -190,7 +192,7 @@ void musicscore::drawFlakes(levelscore *levels) { //if (iter->second->activated&&(!iter->second->disintegrated)) iter->second->disintegrate(); ofSetColor(255,255,255); - iter->second->draw((notemap(iter->second->num)*300)+100,ofGetHeight()-(thisstart*heightStep)); + iter->second->draw(gridX[notemap(iter->second->num)]*ofGetWidth(),ofGetHeight()-(thisstart*heightStep),scale); //todo - make all drawing resolution independent } @@ -201,16 +203,17 @@ void musicscore::drawFlakes(levelscore *levels) { missedLast=false; map::iterator missed=flakes.end(); int scoreTime=ofGetElapsedTimeMillis()-startTime; - for (iter = flakes.lower_bound(levels->getLowerBound(levels->getLevel(scoreStart))); iter != flakes.upper_bound(scoreStart); iter++){ + for (iter = flakes.lower_bound(levels->getLowerBound(levels->getLevel(scoreStart))); iter != flakes.lower_bound(scoreStart); iter++){ if (!iter->second->activated) { missedFlakes++; missed=iter; } missedLast=!iter->second->activated; - } + } + //at this point missed points to the latest unactivated flake in the level if ((missed!=flakes.end())&&(missedFlake!=missed)) { missedFlake=missed; - missedNote=notemap(iter->second->num); + missedNote=notemap(missed->second->num); } else missedNote=-1; @@ -220,7 +223,10 @@ void musicscore::playerControl(int key,int threshold){ map::iterator iter; int scoreTime=ofGetElapsedTimeMillis()-startTime; for (iter = flakes.lower_bound(scoreTime-threshold); iter != flakes.upper_bound(scoreTime+threshold); iter++) { - if (key==notemap(iter->second->num)) iter->second->activate(); + if (key==notemap(iter->second->num)) { + iter->second->activate(); + hitNote=key; + } } } //--------------------------------------------------------------------------------------------------------------------------------------------- @@ -296,4 +302,9 @@ void song::playerControl(int key){ } int song::missedNote(){ return notes.missedNote; +} +int song::hitNote(){ + int n=notes.hitNote; + notes.hitNote=-1; + return n; } diff --git a/vfg/src/music.h b/vfg/src/music.h index f9317de..7e54292 100755 --- a/vfg/src/music.h +++ b/vfg/src/music.h @@ -4,6 +4,10 @@ #include "ofxXmlSettings.h" #include "Puppet.h" +//Grid for drawing +static float gridX[3]={0.3,0.5,0.7}; +static float gridY[1]={0.8}; + //event times are absolute integer milliseconds //--------------------------------------------------------------------------------------------------------------------------------------------- class levelscore { @@ -73,8 +77,8 @@ class flake: public note, public Puppet { activated=true; puppet.play("shatter"); } - void draw(float x, float y) { - if (!activated||puppet.isPlaying()) puppet.draw(x,y); + void draw(float x, float y,float scale) { + if (!activated||puppet.isPlaying()) puppet.draw(x,y,scale); } }; //--------------------------------------------------------------------------------------------------------------------------------------------- @@ -144,6 +148,7 @@ class musicscore: public score { int missedFlakes; int missedNote; + int hitNote; bool missedLast; bool perfect; @@ -170,6 +175,7 @@ class song { void drawNotes(); void draw(); int missedNote(); + int hitNote(); bool isPlaying; void playerControl(int key); private: diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp index 8dd6110..bcef98e 100755 --- a/vfg/src/testApp.cpp +++ b/vfg/src/testApp.cpp @@ -3,8 +3,6 @@ //-------------------------------------------------------------- void testApp::setup(){ - //for (float i=0;i<1.2;i+=0.1) printf("%f in level %i bound %f\n",i,lives->getLevel(i),lives->getLowerBound(lives->getLevel(i))); - 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->setTimeframe(2500); testsong->setFlakeThresh(1000,100); @@ -12,28 +10,21 @@ void testApp::setup(){ ofSetBackgroundAuto(false); ofBackground(0,0,0); - //printf("%s\n",ofVAArgsToString("Penguin-Clap-Blue_00000.png", 1).c_str()); ??? + /* 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"); - /* - penguins[0].load("Penguin-Clap-Blue/Penguin-Clap-Blue_%05i.png",20); - penguins[0].setAnchorPercent(0.5, 1.0); - penguins[0].setFrameRate(50); - penguins[0].setLoop(false); - penguins[1].load("Penguin-Clap-Purple/Penguin-Clap-Purple_%05i.png",20); - penguins[1].setAnchorPercent(0.5, 1.0); - penguins[1].setFrameRate(50); - penguins[1].setLoop(false); - penguins[2].load("Penguin-Clap-Green/Penguin-Clap-Green_%05i.png",20); - penguins[2].setAnchorPercent(0.5, 1.0); - penguins[2].setFrameRate(50); - penguins[2].setLoop(false); + 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"); */ - - //printf(ofSystem("ls -la").c_str()); + + + loadanimals("Penguins"); + playanimal =&playanimals; //testpenguin.load("Penguin-Blue.xml"); //debug: commented out: 436m 257m @@ -42,11 +33,34 @@ void testApp::setup(){ //release: commented out: 436m 256m //508fr 1.4s load in use: 836m 443m + background.loadMovie("Background_v3.mp4"); + background.setLoopState(OF_LOOP_NORMAL); + background.play(); + + vignette.loadImage("Vignette.png"); showFPS=false; } +void testApp::loadanimals(string which) { + playanimals.clear(); + + for (int i=0;i<3;i++) playanimals.push_back(Animal()); + + if (which=="Penguins") { + playanimals[0].load("Penguin-Blue.xml"); + playanimals[1].load("Penguin-Purple.xml"); + playanimals[2].load("Penguin-Green.xml"); + } + else { + playanimals[0].load("Raccoon-Blue.xml"); + playanimals[1].load("Raccoon-Purple.xml"); + playanimals[2].load("Raccoon-Green.xml"); + } + +} + void testApp::exit(){ delete testsong; } @@ -59,28 +73,39 @@ void testApp::update(){ } else if (ret>0) { testsong->playerControl(ret); - penguins[ret-1].playNow("Clap"); + (*playanimal)[ret-1].playNow("Clap"); } for (int i=0;i<3;i++) { - penguins[i].update(); + (*playanimal)[i].update(); } + background.update(); } //-------------------------------------------------------------- void testApp::draw(){ + ofDisableAlphaBlending(); + ofSetColor(255,255,255); + background.draw(0,0,ofGetWidth(),ofGetHeight()); + float scale=ofGetHeight()/1080.0f; + ofEnableAlphaBlending(); + vignette.draw(0,0,ofGetWidth(),ofGetHeight()); //ofBackground(0,0,0,0.1); + /* ofSetColor(0,0,0,100); ofRect(0,0,ofGetWidth(),ofGetHeight()); + */ if (testsong->isPlaying) { ofSetColor(255,255,255); testsong->drawNotes(); int missed=testsong->missedNote(); - if (missed>-1) penguins[missed].playNow("Shudder"); + if (missed>-1) (*playanimal)[missed].playNow("Shudder"); + int hit=testsong->hitNote(); + if (hit>-1) (*playanimal)[hit].play("Catch"); } ofSetColor(255,255,255); - for (int i=0;i<3;i++) penguins[i].draw((i*300)+100,600); + for (int i=0;i<3;i++) (*playanimal)[i].draw(gridX[i]*ofGetWidth(),gridY[0]*ofGetHeight(),scale); if (testsong->isPlaying) { ofSetColor(255,255,255); testsong->draw(); @@ -103,7 +128,7 @@ void testApp::keyPressed(int key){ case '2': case '3': testsong->playerControl(key-'1'); - penguins[key-'1'].playNow("Clap"); + (*playanimal)[key-'1'].playNow("Clap"); break; case 's': game.startGame(); @@ -111,6 +136,12 @@ void testApp::keyPressed(int key){ case 'f': showFPS=!showFPS; break; + case 'r': + loadanimals("Raccoons"); + break; + case 'p': + loadanimals("Penguins"); + break; } } diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h index f62c098..4ab807f 100755 --- a/vfg/src/testApp.h +++ b/vfg/src/testApp.h @@ -72,10 +72,22 @@ class testApp : public ofBaseApp{ void windowResized(int w, int h); void dragEvent(ofDragInfo dragInfo); void gotMessage(ofMessage msg); + + void loadanimals(string which); + + ofVideoPlayer background; + ofImage vignette; song *testsong; + /* vector penguins; + vector raccoons; + */ + + vector playanimals; + + vector* playanimal; Puppet testpenguin; diff --git a/vfg/vfg.cbp b/vfg/vfg.cbp index 7480047..21ad2a0 100755 --- a/vfg/vfg.cbp +++ b/vfg/vfg.cbp @@ -33,6 +33,12 @@ + + + + diff --git a/vfg/vfg.layout b/vfg/vfg.layout index 4c64d90..48e2935 100644 --- a/vfg/vfg.layout +++ b/vfg/vfg.layout @@ -1,31 +1,34 @@ - + - + - - + + - - + + - + + + + - - + + - + - - + + - - + + -- cgit v1.2.3