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/src/music.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'vfg/src/music.cpp') 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; } -- cgit v1.2.3