#pragma once #include "ofMain.h" #include "ofxXmlSettings.h" #include "Puppet.h" //Grid for drawing static float gridX[4]={0.1083,0.3,0.5,0.7}; static float gridY[2]={0.7713,0.963}; //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{ int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0); name=XML.getAttribute("VFxmas", "name","",0); length=XML.getAttribute("VFxmas", "length",0,0)*multiplier; if(XML.pushTag("VFxmas")) { for (int i=0;i::iterator iter=levels.end(); iter--; for (int i=0;ifirst;i+=500) { printf("time %i: level %i, nextleveltime %i\n",i,getLevel(i), nextLevelTime(i)); } } void makePractice(int l){ levels[0]=0; levels[l]=0; length=l; } int getLives(int time) { map::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::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::iterator iter=levels.begin(); int bound=0; for (int i=0;i<=level;i++) { bound=iter->first; iter++; } return bound; } int nextLevelTime(int time) { map::iterator iter; int level=-1; for (iter = levels.begin(); iter != levels.end(); ++iter) { if (iter->first>time) return iter->first-time; } return 2<<20; // a big number } int length; string name; private: map levels; }; //--------------------------------------------------------------------------------------------------------------------------------------------- class note { public: note(int n,int v,int d=0) { num=n; velocity=v; duration=d; } int num; int velocity; int duration; //may be needed another time? }; //--------------------------------------------------------------------------------------------------------------------------------------------- class flake: public note, public Puppet { public: flake(int n,int v,int d=0) : note(n,v,d) { activated=false; } Puppet puppet; bool activated; void activate() { activated=true; puppet.play("shatter"); } void draw(float x, float y,float scale) { if (!activated||puppet.isPlaying()) puppet.draw(x,y,scale); } }; //--------------------------------------------------------------------------------------------------------------------------------------------- class lyric { public: lyric(string s,int d) { text=s; duration=d; } string text; int duration; }; //--------------------------------------------------------------------------------------------------------------------------------------------- class score { //basics of timelime public: long startTime; void start() { startTime=ofGetElapsedTimeMillis(); } void start(int _st) { startTime=_st; } ofxXmlSettings XML; }; //--------------------------------------------------------------------------------------------------------------------------------------------- class lyricscore: public score { //draws lyrics to screen for a certain time public: lyricscore() { fadeout=500; //ms loadFont(); } 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",1000,0); if(XML.pushTag("VFxmas")) { for (int i=0;i lyrics; ofTrueTypeFont font; int fadeout; }; //--------------------------------------------------------------------------------------------------------------------------------------------- class musicscore: public score { //draws notes to screen for a certain time and certain parameters, checks when they become ready public: musicscore(); void parseMidi(string filename); void setTimeframe(int millis); void drawNotes(float hOffs,levelscore *levels); void drawFlakes(float hOffs,levelscore *levels,float scale); void playerControl(int key); void makeRandomNotes(int length,int startFreq,int endFreq); void makeFlakes(int threshStart,int threshEnd,levelscore *levels); void printNotes(); int missedFlakes; int missedNote; int hitNote; bool missedLast; bool perfect; int keyThresh; private: map notes; map flakes; map::iterator missedFlake; int timeframe; float nowpoint; vector snowflakes; }; //--------------------------------------------------------------------------------------------------------------------------------------------- class song { public: song(); virtual ~song(); 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 drawNotes(float hOffs); void draw(float hOffs,float scale,bool showLyrics=true); int missedNote(); int hitNote(); bool isPlaying; void playerControl(int key); int getLevel(long time); int getCurrentTime(); string getScoreString(); string getName(); int getLength(); bool isGameover(); void gameOver(); bool isFinished(); bool gameover; void resize(); musicscore notes; private: ofSoundPlayer backing; ofSoundPlayer melody; lyricscore lyrics; levelscore levels; int startTime,gameoverTime; bool isPreroll,isPractice; int fThreshStart,fThreshEnd,fademillis; }; //--------------------------------------------------------------------------------------------------------------------------------------------- /* 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 */