summaryrefslogtreecommitdiff
path: root/vfg/src/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/music.cpp')
-rwxr-xr-xvfg/src/music.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index b5b584c..32f9d3e 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -3,13 +3,13 @@
//event times & durations are absolute integer milliseconds
int notemap(int n) {
- //nonlinear mapping of notes to 3 columns - space 5,4,7
- //note drawing 46h - 52h
+ //nonlinear mapping of notes to 3 columns - space 5,4,7 - trying 5,5,6
+ //note drawing 46h - 52h
int numnotes=16;
int firstnote=70;
int note=n-firstnote;
if (note<5) return 0;
- else if (note <9) return 1;
+ else if (note <10) return 1;
else return 2;
}
//----------------------------------------------------------------------------------------------------------
@@ -22,7 +22,7 @@ void lyricscore::draw(){
if ((iter->first+iter->second->duration)>scoreTime) { //outpoint of lyric previous to the one next soonest is afterwards => this lyric is visible
int alpha=((iter->first+iter->second->duration)-scoreTime)<fadeout?(int)((((float)((iter->first+iter->second->duration)-scoreTime))/((float)fadeout))*255.0f):255;
ofSetColor(255,255,255,alpha);
- font.drawString(iter->second->text,(ofGetWidth()/2)-(font.stringWidth(iter->second->text)/2.0f), ypos);
+ font.drawString(iter->second->text,(ofGetWidth()/2)-(font.stringWidth(iter->second->text)/2.0f), gridY[1]*ofGetHeight());
}
}
}
@@ -164,16 +164,15 @@ 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),120);
+ ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,100),(((float)(thisstart*heightStep))/ofGetHeight()*128)+32);
ofRect(thisnote*widthStep,ofGetHeight()-(thisstart*heightStep),widthStep,-(thislength*heightStep));
}
}
-void musicscore::drawFlakes(levelscore *levels) {
+void musicscore::drawFlakes(levelscore *levels,float scale) {
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;
@@ -192,7 +191,7 @@ void musicscore::drawFlakes(levelscore *levels) {
//if (iter->second->activated&&(!iter->second->disintegrated)) iter->second->disintegrate();
ofSetColor(255,255,255);
- iter->second->draw(gridX[notemap(iter->second->num)]*ofGetWidth(),ofGetHeight()-(thisstart*heightStep),scale);
+ iter->second->draw(gridX[notemap(iter->second->num)+1]*ofGetWidth(),ofGetHeight()-(thisstart*heightStep),scale);
//todo - make all drawing resolution independent
}
@@ -246,6 +245,9 @@ void song::setFlakeThresh(int tS,int tE) {
fThreshStart=tS;
fThreshEnd=tE;
}
+int song::getCurrentTime(){
+ return ofGetElapsedTimeMillis()-startTime;
+}
void song::play() {
backing.play();
melody.play();
@@ -271,7 +273,7 @@ void song::preRoll(long preroll) {
void song::drawNotes(){
notes.drawNotes(&levels);
}
-void song::draw(){
+void song::draw(float scale){
int songTime=ofGetElapsedTimeMillis()-startTime;
if (isPlaying) {
if (isPreroll) {
@@ -291,11 +293,15 @@ void song::draw(){
}
}
else melody.setVolume(1.0f);
- notes.drawFlakes(&levels);
+ notes.drawFlakes(&levels,scale);
lyrics.draw();
+ if (songTime>levels.length) {
+ printf("stopping: %i (%i)\n",songTime,levels.length);
+ stop();
+ }
}
- ofDrawBitmapString(ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)),10,ofGetHeight()-15);
+ ofDrawBitmapString(ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)),10,(ofGetHeight()*gridY[1])-3);
}
void song::playerControl(int key){
notes.playerControl(key,keyThresh);