summaryrefslogtreecommitdiff
path: root/vfg/src/music.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@gray.(none)>2012-11-22 11:00:03 +0000
committerTim Redfern <tim@gray.(none)>2012-11-22 11:00:03 +0000
commit9dc429df9dbd1a5ae0f93d553ccfde7ab37a53a2 (patch)
treec0891b8554cf6973aae12ade27bd85be2a1f6a09 /vfg/src/music.cpp
parentb4d89c0a9029739d2af1705b371dc28f27b6d2dc (diff)
gameplay good: up against memory limit
Diffstat (limited to 'vfg/src/music.cpp')
-rwxr-xr-xvfg/src/music.cpp23
1 files changed, 17 insertions, 6 deletions
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<int,flake*>::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<int,flake*>::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;
}