#include "testApp.h" //-------------------------------------------------------------- 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->setTimeframe(2500); 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 =&playanimals; //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) { testsong->preRoll(250); } else if (ret>0) { testsong->playerControl(ret); (*playanimal)[ret-1].playNow("Clap"); } 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) { 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"); break; case 'p': loadanimals("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){ }