diff options
| author | Tim Redfern <tim@gray.(none)> | 2012-11-05 19:03:32 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@gray.(none)> | 2012-11-05 19:03:32 +0000 |
| commit | b5aba6fcbf2847735b0c43e84d0933797c73f581 (patch) | |
| tree | b6a38a9f11f3501d5f9cd0459af4654881987899 /vfg/src/music.cpp | |
| parent | f4719e4e997a05bb423e9ca691de50bcbf1cb375 (diff) | |
gameplay demo #1
Diffstat (limited to 'vfg/src/music.cpp')
| -rwxr-xr-x | vfg/src/music.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 286bdcb..096e630 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -11,7 +11,7 @@ note::note(int n,int v,int d){ //---------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------------------------------------
musicscore::musicscore() {
- timeframe=10000;
+ timeframe=2000;
flake.loadImage("flake.png");
flake.setAnchorPercent(0.5,0.5);
}
@@ -105,21 +105,21 @@ void musicscore::parseMidi(string filename){ int lastTime=0;
stars[notes.begin()->first]=notes.begin()->second;
for (iter1 = notes.begin(); iter1 != notes.end(); iter1++) {
- if ((iter1->second->num/5!=lastNote->num/5)||(lastTime-iter1->first>noteThresh)) {
+ if ((iter1->second->num/5!=lastNote->num/5)||(iter1->first-lastTime>noteThresh)) {
stars[iter1->first]=iter1->second;
}
lastNote=iter1->second;
lastTime=iter1->first;
}
-
- interactionThresh=100; //how long player has to respond
+
+ interactionThresh=200; //how long player has to respond
missedTime=-1;
-
-
+
+
}
void musicscore::setTimeframe(int millis) {timeframe=millis;}
void musicscore::draw() {
- ofEnableAlphaBlending();
+ ofEnableAlphaBlending();
int scoreStart=ofGetElapsedTimeMillis()-startTime;
int scoreEnd=scoreStart+timeframe;
//temporary drawing method 46h - 52h
@@ -128,28 +128,28 @@ void musicscore::draw() { float widthStep=((float)ofGetWidth())/numnotes;
float heightStep=((float)ofGetHeight())/timeframe;
map<int,note*>::iterator iter;
-
- for (iter = notes.lower_bound(scoreStart); iter != notes.upper_bound(scoreEnd); ++iter) {
+
+ for (iter = notes.lower_bound(scoreStart); iter != notes.upper_bound(scoreEnd); ++iter) {
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));
ofRect(thisnote*widthStep,ofGetHeight()-(thisstart*heightStep),widthStep,-(thislength*heightStep));
-
+
//different methods for generating flakes
//ideally theres a variable clumping factor, this means pre-processing the flakes though
-
+
//ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
-
+
//flake.draw((thisnote+0.5f)*widthStep,ofGetHeight()-(thisstart*heightStep));
//flake.draw((iter->second->updown*ofGetWidth()*0.33)+(ofGetWidth()*0.5),ofGetHeight()-(thisstart*heightStep));
//flake.draw((((thisnote/5)*5)+3.5f)*widthStep,ofGetHeight()-(thisstart*heightStep));
}
- for (iter = stars.lower_bound(scoreStart); iter != stars.upper_bound(scoreEnd); ++iter) {
+ for (iter = stars.lower_bound(scoreStart-200); iter != stars.upper_bound(scoreEnd); ++iter) { //added extra 200ms for flake to leave screen
int thisnote=iter->second->num-firstnote;
int thisstart=iter->first-scoreStart;
int thislength=iter->second->duration;
-
+
// check player interaction
if (thisstart<interactionThresh) {
//this star needs to be interacted with
@@ -160,7 +160,7 @@ void musicscore::draw() { }
if (iter->second->activated) ofSetColor(255,255,255);
else ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
- flake.draw((((thisnote/5)*5)+3.5f)*widthStep,ofGetHeight()-(thisstart*heightStep));
+ flake.draw((((thisnote/5)*5)+3.5f)*widthStep,ofGetHeight()-(thisstart*heightStep),flake.getWidth()/2,flake.getHeight()/2);
}
//check for unactivated stars. must be a better way
missedTime=-1;
@@ -188,18 +188,18 @@ void song::play() { melody.play();
startTime=ofGetElapsedTimeMillis();
notes.startTime=startTime;
- isPlaying=true;
+ isPlaying=true;
}
-void song::stop() {
+void song::stop() {
backing.stop();
melody.stop();
- isPlaying=false;
+ isPlaying=false;
}
void song::preRoll(long preroll) {
startTime=ofGetElapsedTimeMillis()+preroll;
notes.startTime=startTime;
isPreroll=true;
- isPlaying=true;
+ isPlaying=true;
}
void song::draw(){
//how to deal with end/ track length/ part of game?
@@ -212,7 +212,7 @@ void song::draw(){ }
if (notes.missedTime>0) {
if (notes.missedTime>missedInterval) stop();
- else melody.setVolume(1.0f-((float)notes.missedTime/(float)missedInterval));
+ else melody.setVolume(0.0f); //1.0f-((float)notes.missedTime/(float)missedInterval));
}
else melody.setVolume(1.0f);
notes.draw();
|
