summaryrefslogtreecommitdiff
path: root/vfg/src/music.h
diff options
context:
space:
mode:
authorTim Redfern <tim@gray.(none)>2012-11-09 18:55:44 +0000
committerTim Redfern <tim@gray.(none)>2012-11-09 18:55:44 +0000
commiteda90b505d3a583e0c3788ca1ad924d75b02fe01 (patch)
treef533eee587bca2a4f3cddcf70abddc91b39d6cd8 /vfg/src/music.h
parentb5aba6fcbf2847735b0c43e84d0933797c73f581 (diff)
levels working, lyrics loading
Diffstat (limited to 'vfg/src/music.h')
-rwxr-xr-xvfg/src/music.h133
1 files changed, 114 insertions, 19 deletions
diff --git a/vfg/src/music.h b/vfg/src/music.h
index 39ffd95..292e05f 100755
--- a/vfg/src/music.h
+++ b/vfg/src/music.h
@@ -5,15 +5,75 @@
//event times are absolute integer milliseconds
//---------------------------------------------------------------------------------------------------------------------------------------------
+class levelscore {
+ public:
+ void load(string filename) {
+ ofxXmlSettings XML;
+ if( !XML.loadFile(filename) ){
+ printf("unable to load %s check data/ folder\n",filename.c_str());
+ }else{
+ if(XML.pushTag("VFxmas")) {
+ for (int i=0;i<XML.getNumTags("Level");i++) {
+ levels[XML.getAttribute("Level", "Time",0,i)]=XML.getAttribute("Level", "Lives",0,i);
+ }
+ printf("processed %s: %i difficulty levels \n",filename.c_str(),levels.size());
+ }
+ }
+ }
+ int getLives(int time) {
+ map<int,int>::iterator iter;
+ int lives=0;
+ for (iter = levels.begin(); iter != levels.end(); ++iter) {
+ if (iter->first<=time) lives=iter->second;
+ else break;
+ }
+ return lives;
+ }
+ int getLevel(int time) {
+ map<int,int>::iterator iter;
+ int level=-1;
+ for (iter = levels.begin(); iter != levels.end(); ++iter) {
+ if (iter->first<=time) level++;
+ else break;
+ }
+ return level;
+ }
+ int getLowerBound(int level) {
+ map<int,int>::iterator iter=levels.begin();
+ int bound=0;
+ for (int i=0;i<=level;i++) {
+ bound=iter->first;
+ iter++;
+ }
+ return bound;
+ }
+ private:
+ map<int,int> levels;
+};
+//---------------------------------------------------------------------------------------------------------------------------------------------
class note {
public:
- note(int n,int v,int d=0);
+ note(int n,int v,int d=0) {
+ num=n;
+ velocity=v;
+ duration=d;
+ activated=false;
+ }
int num;
int velocity;
int duration; //may be needed another time?
- int updown; //-1 0 1 used for 3-button interaction
bool activated;
- void playerActivated() { activated=true; }
+ void activate() { activated=true; }
+};
+//---------------------------------------------------------------------------------------------------------------------------------------------
+class lyric {
+ public:
+ lyric(string s,int d) {
+ text=s;
+ duration=d;
+ }
+ string text;
+ int duration;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
class score {
@@ -27,6 +87,23 @@ class score {
class lyricscore: public score {
//draws lyrics to screen for a certain time
public:
+ void load(string filename) {
+ if( !XML.loadFile(filename) ){
+ printf("unable to load %s check data/ folder\n",filename.c_str());
+ }else{
+ int multiplier=1000/XML.getAttribute("VFxmas", "timebase",0,0);
+ if(XML.pushTag("VFxmas")) {
+ for (int i=0;i<XML.getNumTags("Lyric");i++) {
+ int in=XML.getAttribute("Lyric", "In",0,i)*multiplier;
+ lyrics[in]=new lyric(XML.getValue("Lyric","",i),(XML.getAttribute("Lyric", "Out",0,i)*multiplier)-in);
+ }
+ printf("processed %s: %i lyrics \n",filename.c_str(),lyrics.size());
+ }
+
+ }
+ }
+ private:
+ map<int,lyric*> lyrics;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
class musicscore: public score {
@@ -35,31 +112,30 @@ class musicscore: public score {
musicscore();
void parseMidi(string filename);
void setTimeframe(int millis);
- void draw();
-
- void playerControl(int key);
- //in wrong object?
- int missedTime;
+ void draw(levelscore *levels);
+ void playerControl(int key,int threshold);
+ void makeFlakes(int threshStart,int threshEnd);
+
+ int missedFlakes;
+ bool missedLast;
+ bool perfect;
+
private:
- map<int,note*> notes;
- map<int,note*> stars;
+ map<int,note*> notes;
+ map<int,note*> flakes;
int timeframe;
ofImage flake;
-
- //in wrong object?
- int interactionThresh;
-
-
- int playerKey;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
class song {
public:
- song(string backfile,string melfile,string musfile);
+ song(string backfile,string melfile,string musfile,string lyricfile,string levelfile);
void play();
void stop();
void preRoll(long preroll);
void setTimeframe(int millis);
+ void setFlakeThresh(int tS,int tE);
+ void setKeythresh(int millis);
void draw();
bool isPlaying;
void playerControl(int key);
@@ -68,12 +144,31 @@ class song {
ofSoundPlayer melody;
lyricscore lyrics;
musicscore notes;
+ levelscore levels;
long startTime;
bool isPreroll;
-
- int missedInterval;
+ int fThreshStart,fThreshEnd,keyThresh;
};
//---------------------------------------------------------------------------------------------------------------------------------------------
+/*
+Game
+Animation & Sound Demo – NK to overlay latest version of Deck the Halls on 10 second animated sequence by COB Wednesday 7th November for visual and aural aesthetic sign-off. RM to send through latest version of Deck the Halls today (6th November).
+Game Development – TR presented initial demo today. Usability looks good. NK to provide first suite of graphics by COB Wednesday 7th November.
+Latency Test – TR and GK to perform end-to-end latency test next Monday 12th November once Vodafone have connected the 1800 number to the 01 number. Any issues noted in the testing to be flagged to BL.
+Game Over – Players who miss a certain amount of notes in a row will be kicked out of the game early. The number of notes that can be missed in a row will decrease as the game goes on (subject to testing and tweaking):
+
+Stage 1 – N/A (it will not be possible to be kicked out in Stage 1)
+Stage 2 – 5 notes missed will mean Game Over
+Stage 3 – 4 notes missed will mean Game Over
+Stage 4 – 3 notes missed will mean Game Over
+
+Scoring – Scoring will be based on the level of the game you achieve. There will be 4 scoring brackets (subject to testing and tweaking):
+
+Scoring Bracket 1 - Those who make it to Level 2 (see above - it's not possible to be kicked out in Level 1)
+Scoring Bracket 2 – Those who make it to Level 3
+Scoring Bracket 3 – Those who make it to Level 4
+Scoring Bracket 4 – Those who don't miss any notes in Level 4
+*/