summaryrefslogtreecommitdiff
path: root/vfg/src/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/music.cpp')
-rwxr-xr-xvfg/src/music.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index 9fd88d3..ed442cd 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -29,10 +29,15 @@ void lyricscore::draw(){
//----------------------------------------------------------------------------------------------------------
musicscore::musicscore() {
timeframe=2000;
- flake.loadImage("flake.png");
- flake.setAnchorPercent(0.5,0.5);
missedLast=false;
nowpoint=1.0f;
+
+ snowflakes.push_back(Puppet());
+ snowflakes.push_back(Puppet());
+ snowflakes.push_back(Puppet());
+ snowflakes[0].load("Snowflake-Blue.xml");
+ snowflakes[1].load("Snowflake-Purple.xml");
+ snowflakes[2].load("Snowflake-Green.xml");
}
void musicscore::parseMidi(string filename){
// millis = 60000 / (BPM * PPQ)
@@ -126,11 +131,13 @@ void musicscore::makeFlakes(int threshStart,int threshEnd){
iter = notes.end();
iter--;
float songDuration=iter->first;
- flakes[notes.begin()->first]=notes.begin()->second;
+ flakes[notes.begin()->first]=new flake(notes.begin()->second->num,notes.begin()->second->velocity,notes.begin()->second->duration);
+ 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)))) {
- flakes[iter->first]=iter->second;
+ 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;
@@ -167,17 +174,22 @@ void musicscore::drawFlakes(levelscore *levels) {
int firstnote=70;
float widthStep=((float)ofGetWidth())/numnotes;
float heightStep=((float)ofGetHeight())/timeframe;
- map<int,note*>::iterator iter;
+ map<int,flake*>::iterator iter;
//draw flakes
for (iter = flakes.lower_bound(scoreStart); iter != flakes.upper_bound(scoreEnd); iter++) {
int thisnote=iter->second->num-firstnote;
int thisstart=iter->first-scoreStart;
int thislength=iter->second->duration;
- if (iter->second->activated) ofSetColor(255,255,255);
- else ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
- flake.draw((notemap(iter->second->num)*300)+100,ofGetHeight()-(thisstart*heightStep),flake.getWidth()/2,flake.getHeight()/2);
-
+
+ //if (iter->second->activated) ofSetColor(255,255,255);
+ //else ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
+
+ //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));
//todo - make all drawing resolution independent
+
}
//check for unactivated flakes within this segment: is there a more efficient way?
//is it the number of flakes they can lose per segment?
@@ -192,10 +204,10 @@ void musicscore::drawFlakes(levelscore *levels) {
ofDisableAlphaBlending();
}
void musicscore::playerControl(int key,int threshold){
- map<int,note*>::iterator iter;
+ map<int,flake*>::iterator iter;
int scoreTime=ofGetElapsedTimeMillis()-startTime;
for (iter = flakes.lower_bound(scoreTime-threshold); iter != flakes.upper_bound(scoreTime+threshold); iter++) {
- iter->second->activate();
+ if (key==notemap(iter->second->num)) iter->second->activate();
}
}
//---------------------------------------------------------------------------------------------------------------------------------------------