#include "testApp.h" //bug in codeblocks: it sometimes checks for existence of executable from previous project //-------------------------------------------------------------- void testApp::setup(){ //testsong=new song("VODA_MUS_DeckTheHalls-Backing_v.1.5.mp3","VODA_MUS_DeckTheHalls-Melody_v.1.5.mp3","MIDI_DeckTheHalls_MIDI.1.5.xml","Lyrics_DeckTheHalls.1.5.xml","Levels_DeckTheHalls.1.5.xml"); testsong=new song("JingleBells_v.4.0/VODA_MUS_JingleBells_Backing_v.4.0.mp3","JingleBells_v.4.0/VODA_MUS_JingleBells_Melody_v.4.0.mp3","VODA_MUS_JingleBells_MIDI_v.4.0.xml","Lyrics_JingleBells.4.0.xml","Levels_JingleBells.4.0.xml"); testsong->setTimeframe(3000); testsong->setFlakeThresh(1000,100); ofSetBackgroundAuto(false); ofBackground(0,0,0); for (int i=0;i<3;i++) penguins.push_back(Animal()); penguins[0].load("Penguin-Blue.xml"); penguins[1].load("Penguin-Purple.xml"); penguins[2].load("Penguin-Green.xml"); for (int i=0;i<3;i++) raccoons.push_back(Animal()); raccoons[0].load("Raccoon-Blue.xml"); raccoons[1].load("Raccoon-Purple.xml"); raccoons[2].load("Raccoon-Green.xml"); //loadanimals("Raccoons"); playanimal =&penguins; //testpenguin.load("Penguin-Blue.xml"); //debug: commented out: 436m 257m //508fr 1.7s load in use: 837m 444m //release: commented out: 436m 256m //508fr 1.4s load in use: 836m 443m background.loadMovie("Background_v3.mp4"); background.setLoopState(OF_LOOP_NORMAL); background.play(); vignette.loadImage("Vignette.png"); showFPS=false; } /* void testApp::loadanimals(string which) { playanimals.clear(); for (int i=0;i<3;i++) playanimals.push_back(Animal()); if (which=="Penguins") { playanimals[0].load("Penguin-Blue.xml"); playanimals[1].load("Penguin-Purple.xml"); playanimals[2].load("Penguin-Green.xml"); } else { playanimals[0].load("Raccoon-Blue.xml"); playanimals[1].load("Raccoon-Purple.xml"); playanimals[2].load("Raccoon-Green.xml"); } } */ void testApp::exit(){ delete testsong; } //-------------------------------------------------------------- void testApp::update(){ int ret=game.update(); if (ret==1000) { currentlevel=0; testsong->preRoll(250); } else if (ret>48&&ret<52) { testsong->playerControl(ret-48); (*playanimal)[ret-49].playNow("Clap"); } if (testsong->isPlaying&&testsong->getLevel(ofGetElapsedTimeMillis()+2000)>currentlevel) { int anim=ofRandom(1.9999); //this gives a binary random number for (int i=0;i<3;i++) { if (anim) (*playanimal)[i].playNow("Happy"); else (*playanimal)[i].playNow("Jump"); anim=(anim+1)%2; } //printf("finished level %i!\n",currentlevel); currentlevel++; } for (int i=0;i<3;i++) { (*playanimal)[i].update(); } background.update(); } //-------------------------------------------------------------- void testApp::draw(){ ofDisableAlphaBlending(); ofSetColor(255,255,255); background.draw(0,0,ofGetWidth(),ofGetHeight()); float scale=ofGetHeight()/1080.0f; ofEnableAlphaBlending(); vignette.draw(0,0,ofGetWidth(),ofGetHeight()); //ofBackground(0,0,0,0.1); /* ofSetColor(0,0,0,100); ofRect(0,0,ofGetWidth(),ofGetHeight()); */ if (testsong->isPlaying) { ofSetColor(255,255,255); testsong->drawNotes(); int missed=testsong->missedNote(); if (missed>-1) (*playanimal)[missed].playNow("Shudder"); int hit=testsong->hitNote(); if (hit>-1) (*playanimal)[hit].play("Catch"); } ofSetColor(255,255,255); for (int i=0;i<3;i++) (*playanimal)[i].draw(gridX[i]*ofGetWidth(),gridY[0]*ofGetHeight(),scale); if (testsong->isPlaying) { ofSetColor(255,255,255); testsong->draw(); } else ofDrawBitmapString("game over!", (ofGetWidth()/2)-25,(ofGetHeight()/2)-5); if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate()), ofGetWidth()-50,ofGetHeight()-15); } //-------------------------------------------------------------- void testApp::keyPressed(int key){ switch (key) { case ' ': if (!testsong->isPlaying) { currentlevel=0; testsong->preRoll(250); } break; case '1': case '2': case '3': testsong->playerControl(key-'1'); (*playanimal)[key-'1'].playNow("Clap"); break; case 's': game.startGame(); break; case 'f': showFPS=!showFPS; break; case 'r': //loadanimals("Raccoons"); playanimal =&raccoons; break; case 'p': //loadanimals("Penguins"); playanimal =&penguins; break; } } //-------------------------------------------------------------- void testApp::keyReleased(int key){ switch (key) { case '1': case '2': case '3': break; } } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }