summaryrefslogtreecommitdiff
path: root/vfg/src/testApp.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2012-11-30 13:30:48 +0000
committerComment <tim@gray.(none)>2012-11-30 13:30:48 +0000
commitbbeed54d2c0572d9fc12edab14781dd544dc149a (patch)
treeeec54a5a9741513c545abec4c750a85e1eb7e259 /vfg/src/testApp.cpp
parent7ae1f870faebb65e9ee3a064fc43ef2fc6955a84 (diff)
demo v0.9
Diffstat (limited to 'vfg/src/testApp.cpp')
-rwxr-xr-xvfg/src/testApp.cpp227
1 files changed, 171 insertions, 56 deletions
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 53cfa95..5324b23 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -1,9 +1,30 @@
#include "testApp.h"
//bug in codeblocks: it sometimes checks for existence of executable from previous project
+
//--------------------------------------------------------------
+guiWindow::~guiWindow(){
+ cout << "gui window destroyed" << endl;
+}
+void guiWindow::setup(){}
+void guiWindow::setParent(testApp *p){
+ parent=p;
+}
+void guiWindow::draw(){
+
+ parent->gui.draw();
+
+}
+void guiWindow::dragEvent(ofDragInfo dragInfo, ofxFenster* win){
+ parent->dragEvent(dragInfo);
+}
+void guiWindow::windowMoved(int x,int y){
+ //printf("window moved!\n");
+}
+
+//----------------------------------------------------------------------
void testApp::setup(){
- //songs.push_back(new song("WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Backing_v.2.1.mp3","WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Lead_v.2.1.mp3","VODA_MUS_WEWISHU_Midi_v.2.1.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml"));
+ songs.push_back(new song("WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Backing_v.2.1.mp3","WeWishYouAMerryChistmas_v.2.1/VODA_MUS_WEWISHU_Lead_v.2.1.mp3","VODA_MUS_WEWISHU_Midi_v.2.2.xml","Lyrics_WeWishYou.2.1.xml","Levels_WeWishYou.2.1.xml"));
songs.push_back(new song("DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Backing_v.4.0.mp3","DeckTheHalls_v.4.0/VODA_MUS_DeckTheHalls-Lead_v.4.0.mp3","VODA_MIDI_DeckTheHalls-v.4.0.xml","Lyrics_DeckTheHalls.4.0.xml","Levels_DeckTheHalls.4.0.xml"));
songs.push_back(new song("DingDong.v.2.2/VODA_MUS_DingDong_Backing_v.2.2.mp3","DingDong.v.2.2/VODA_MUS_DingDong_Melody_v.2.2.mp3","VODA_MIDI_DingDong_v.2.2.xml","Lyrics_DingDong.2.2.xml","Levels_DingDong.2.2.xml"));
songs.push_back(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"));
@@ -19,10 +40,12 @@ void testApp::setup(){
penguins[1].load("Penguin-Purple.xml");
penguins[2].load("Penguin-Green.xml");
+ /* temp save time
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");
+ */
tags.push_back(new Tag("Tags/TAG_Get-Ready.png",2000,0.5,0));
tags.push_back(new Tag("Tags/TAG_Level-1.png",3000,0.5,0));
@@ -49,6 +72,12 @@ void testApp::setup(){
//release: commented out: 436m 256m
//508fr 1.4s load in use: 836m 443m
+
+ intro.loadMovie("Game-Demo_v3.mp4");
+ intro.setLoopState(OF_LOOP_NONE);
+
+ advert.loadMovie("GW2003761_GRY-VFBR055-060_MPEG_hi.mpg");
+ advert.setLoopState(OF_LOOP_NONE);
background.loadMovie("Background_v3.mp4");
background.setLoopState(OF_LOOP_NORMAL);
@@ -58,9 +87,32 @@ void testApp::setup(){
showFPS=true;
showVis=true;
+ fullscreenoutput=false;
currentsong=0;
nextsong=0;
+ gamestate=GAME_READY;
+
+
+ guiWin=new guiWindow();
+ gui.setup("","panel.xml",0,0);
+
+ threshStart=2000;
+ gui.add(tS.setup("start threshold",threshStart,0,4000,255));
+ threshEnd=500;
+ gui.add(tE.setup("end threshold",threshEnd,0,4000,255));
+ timescale=5000;
+ gui.add(ts.setup("timescale",timescale,0,10000,255));
+ keyThresh=1500;
+ gui.add(kT.setup("keythresh",keyThresh,0,4000,255));
+
+ ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW);
+ win->setWindowTitle("config");
+ win->addListener(guiWin);
+ ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent);
+ guiWin->setup();
+ guiWin->setParent(this);
+
}
/*
void testApp::loadanimals(string which) {
@@ -92,15 +144,16 @@ void testApp::update(){
if (ret==1000) {
currentlevel=0;
currentsong=nextsong;
- songs[currentsong]->setTimeframe(3000);
- songs[currentsong]->setFlakeThresh(1000,100);
- songs[currentsong]->setKeyThresh(1000);
+ songs[currentsong]->setTimeframe(timescale);
+ songs[currentsong]->setFlakeThresh(threshStart,threshEnd);
+ songs[currentsong]->setKeyThresh(keyThresh);
songs[currentsong]->preRoll(750);
tags[0]->play();
nextsong=(nextsong+1)%songs.size();
+ gamestate=GAME_PLAYING;
}
else if (ret>48&&ret<52) {
- songs[currentsong]->playerControl(ret-48);
+ songs[currentsong]->playerControl(ret-49);
(*playanimal)[ret-49].playNow("Clap");
}
if (songs[currentsong]->isPlaying&&songs[currentsong]->getLevel(ofGetElapsedTimeMillis()+4000)>currentlevel) {
@@ -119,55 +172,97 @@ void testApp::update(){
}
background.update();
banner.update();
+ intro.update();
+ advert.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());
- */
+ float hOffs=(ofGetWidth()-ofGetHeight())/2;
+ float bannerscale,scale; //this old chestnut
+ switch(gamestate) {
+ case GAME_READY:
+ case GAME_PLAYING:
+ background.draw(hOffs,0,ofGetHeight(),ofGetHeight());
+ scale=ofGetHeight()/1080.0f;
- if (songs[currentsong]->isPlaying) {
- ofSetColor(255,255,255);
- if (showVis) songs[currentsong]->drawNotes();
- int missed=songs[currentsong]->missedNote();
- if (missed>-1) (*playanimal)[missed].playNow("Shudder");
- int hit=songs[currentsong]->hitNote();
- if (hit>-1) (*playanimal)[hit].play("Catch");
- }
- ofSetColor(255,255,255);
- for (int i=0;i<3;i++) (*playanimal)[i].draw(gridX[i+1]*ofGetWidth(),gridY[0]*ofGetHeight(),scale);
- if (songs[currentsong]->isPlaying) {
- ofSetColor(255,255,255);
- lyricspanel->draw(ofGetWidth()*0.5,ofGetHeight()*gridY[1],scale);
- songs[currentsong]->draw(scale);
- }
- else {
- ofDrawBitmapString("game over!", (ofGetWidth()/2)-25,(ofGetHeight()/2)-5);
- logos[1]->draw(gridX[0]*ofGetWidth(),gridY[1]*ofGetHeight(),scale);
- }
- ofSetColor(255,255,255);
- for (int i=0;i<tags.size();i++) {
- if (tags[i]->isPlaying) tags[i]->draw(0.5f*ofGetWidth(),0,scale);
+ ofEnableAlphaBlending();
+ vignette.draw(hOffs,0,ofGetHeight(),ofGetHeight());
+ //ofBackground(0,0,0,0.1);
+ /*
+ ofSetColor(0,0,0,100);
+ ofRect(0,0,ofGetWidth(),ofGetHeight());
+ */
+
+ if (songs[currentsong]->isPlaying) {
+ ofSetColor(255,255,255);
+ if (showVis) songs[currentsong]->drawNotes(hOffs);
+ int missed=songs[currentsong]->missedNote();
+ if (missed>-1) (*playanimal)[missed].playNow("Shudder");
+ int hit=songs[currentsong]->hitNote();
+ if (hit>-1) (*playanimal)[hit].play("Catch");
+ }
+ else {
+ if (gamestate==GAME_PLAYING) {
+ game.endGame("GOOD!");
+ gamestate=GAME_READY;
+ }
+ }
+ ofSetColor(255,255,255);
+ for (int i=0;i<3;i++) (*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
+ if (songs[currentsong]->isPlaying) {
+ ofSetColor(255,255,255);
+ lyricspanel->draw(ofGetWidth()*0.5,ofGetHeight()*gridY[1],scale);
+ songs[currentsong]->draw(hOffs,scale);
+ }
+ else {
+ ofDrawBitmapString("game over!", (ofGetWidth()/2)-25,(ofGetHeight()/2)-5);
+ logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
+ }
+ ofSetColor(255,255,255);
+ for (int i=0;i<tags.size();i++) {
+ if (tags[i]->isPlaying) tags[i]->draw(0.5f*ofGetWidth(),0,scale);
+ }
+ logos[0]->draw((gridX[0]*ofGetHeight())+hOffs,0,scale);
+ bannerscale=songs[currentsong]->isPlaying?scale*(1.0f-(max(0.0,min(((float)songs[currentsong]->getCurrentTime())*.001,1.0))*0.325)):scale;
+ banner.draw(ofGetWidth()*0.5,0,bannerscale);
+ char buf[30];
+ sprintf(buf,"%.1f",ofGetFrameRate());
+ if (showFPS) ofDrawBitmapString(buf, hOffs+ofGetHeight()-50,(ofGetHeight()*gridY[1])-3);
+ break;
+ case GAME_INTRO:
+ intro.draw(hOffs,0,ofGetHeight(),ofGetHeight());
+ if (intro.getCurrentFrame()==intro.getTotalNumFrames()) {
+ gamestate=GAME_READY;
+ }
+ break;
+ case GAME_ADVERT:
+ float aspect=advert.getHeight()/advert.getWidth();
+ float wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5;
+ advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect);
+ if (advert.getCurrentFrame()==advert.getTotalNumFrames()) {
+ gamestate=GAME_READY;
+ }
+ break;
}
- logos[0]->draw(gridX[0]*ofGetWidth(),0,scale);
- float bannerscale=songs[currentsong]->isPlaying?scale*(1.0f-(max(0.0,min(((float)songs[currentsong]->getCurrentTime())*.001,1.0))*0.325)):scale;
- banner.draw(ofGetWidth()*0.5,0,bannerscale);
- char buf[30];
- sprintf(buf,"%.1f",ofGetFrameRate());
- if (showFPS) ofDrawBitmapString(buf, ofGetWidth()-50,(ofGetHeight()*gridY[1])-3);
}
-
+//--------------------------------------------------------------
+void testApp::keyPressedEvent(ofKeyEventArgs &args) {
+ printf("window key pressed: %i (%c)\n",args.key,args.key);
+ keyPressed(args.key);
+}
+void testApp::keyPressed(int key, ofxFenster* win){
+ printf("window sent %i\n",key);
+ if(key == '='){
+ fullscreenoutput=!fullscreenoutput;
+ win->setFullscreen(fullscreenoutput);
+ printf("resolution: %ix%i %s\n",win->getWidth(),win->getHeight(),fullscreenoutput?"fullscreen":"windowed");
+ }
+ else keyPressed(key);
+}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
switch (key) {
@@ -175,9 +270,9 @@ void testApp::keyPressed(int key){
if (!songs[currentsong]->isPlaying) {
currentlevel=0;
currentsong=nextsong;
- songs[currentsong]->setTimeframe(5000);
- songs[currentsong]->setFlakeThresh(2000,500);
- songs[currentsong]->setKeyThresh(1500);
+ songs[currentsong]->setTimeframe(timescale);
+ songs[currentsong]->setFlakeThresh(threshStart,threshEnd);
+ songs[currentsong]->setKeyThresh(keyThresh);
songs[currentsong]->preRoll(750);
tags[0]->play();
nextsong=(nextsong+1)%songs.size();
@@ -190,7 +285,27 @@ void testApp::keyPressed(int key){
(*playanimal)[key-'1'].playNow("Clap");
break;
case 's':
- game.startGame();
+ if (gamestate==GAME_READY) {
+ game.startGame();
+ }
+ break;
+ case 'e':
+ if (gamestate==GAME_PLAYING) {
+ game.endGame("GOOD!");
+ gamestate=GAME_READY;
+ }
+ break;
+ case 'q':
+ if (gamestate==GAME_READY) {
+ intro.play();
+ gamestate=GAME_INTRO;
+ }
+ break;
+ case 'w':
+ if (gamestate==GAME_READY) {
+ advert.play();
+ gamestate=GAME_ADVERT;
+ }
break;
case 'f':
showFPS=!showFPS;
@@ -198,14 +313,14 @@ void testApp::keyPressed(int key){
case 'v':
showVis=!showVis;
break;
- case 'r':
- //loadanimals("Raccoons");
- playanimal =&raccoons;
- break;
- case 'p':
- //loadanimals("Penguins");
- playanimal =&penguins;
- break;
+ case 'r':
+ //loadanimals("Raccoons");
+ playanimal =&raccoons;
+ break;
+ case 'p':
+ //loadanimals("Penguins");
+ playanimal =&penguins;
+ break;
}
}