summaryrefslogtreecommitdiff
path: root/vfg/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/testApp.cpp')
-rwxr-xr-xvfg/src/testApp.cpp76
1 files changed, 60 insertions, 16 deletions
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index fa8b9aa..6001da4 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -88,7 +88,8 @@ void testApp::setup(){
showFPS=true;
showVis=true;
fullscreenoutput=false;
-
+ fadelength=1000;
+ segmentStartTime=0;
currentsong=0;
nextsong=0;
gamestate=GAME_READY;
@@ -150,7 +151,7 @@ void testApp::update(){
songs[currentsong]->preRoll(5000);
tags[0]->play();
nextsong=(nextsong+1)%songs.size();
- gamestate=GAME_PLAYING;
+ gamestate=GAME_PRACTICE;
}
else if (ret>48&&ret<52) {
songs[currentsong]->playerControl(ret-49);
@@ -172,19 +173,49 @@ void testApp::update(){
}
switch(gamestate) {
case GAME_READY:
+ case GAME_STARTPLAYING:
case GAME_PLAYING:
+ case GAME_ENDPLAYING:
+ case GAME_ENDINGINTRO:
+ case GAME_ENDINGADVERT:
+ case GAME_PRACTICE:
background.update();
banner.update();
break;
+ case GAME_STARTINGINTRO:
+ background.update();
case GAME_INTRO:
intro.update();
break;
+ case GAME_STARTINGADVERT:
+ background.update();
case GAME_ADVERT:
advert.update();
break;
}
}
+/*
+#define GAME_STARTINGINTRO 1
+#define GAME_INTRO 2
+#define GAME_ENDINGINTRO 3
+#define GAME_READY 4
+#define GAME_STARTINGADVERT 5
+#define GAME_ADVERT 6
+#define GAME_ENDINGADVERT 7
+#define GAME_STARTPLAYING 8
+#define GAME_PRACTICE 9
+#define GAME_PLAYING 10
+#define GAME_ENDPLAYING 11
+*/
+//--------------------------------------------------------------
+void testApp::drawBackgroundLayers(){
+ background.draw(hOffs,0,ofGetHeight(),ofGetHeight());
+ scale=ofGetHeight()/1080.0f;
+ ofEnableAlphaBlending();
+ vignette.draw(hOffs,0,ofGetHeight(),ofGetHeight());
+ ofDisableAlphaBlending();
+}
//--------------------------------------------------------------
void testApp::draw(){
ofDisableAlphaBlending();
@@ -192,18 +223,10 @@ void testApp::draw(){
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;
-
- ofEnableAlphaBlending();
- vignette.draw(hOffs,0,ofGetHeight(),ofGetHeight());
- //ofBackground(0,0,0,0.1);
- /*
- ofSetColor(0,0,0,100);
- ofRect(0,0,ofGetWidth(),ofGetHeight());
- */
+ drawBackgroundLayers();
if (songs[currentsong]->isPlaying) {
ofSetColor(255,255,255);
@@ -247,12 +270,32 @@ void testApp::draw(){
gamestate=GAME_READY;
}
break;
+ case GAME_STARTINGADVERT:
+ float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime))/fadelength;
+ if (segamt<0.5) {
+ ofEnableAlphaBlending();
+ ofSetColor(255,255,255,255-(segamt*512));
+ break;
+ }
+ else if (segamt>1.0) {
+ gamestate=GAME_ADVERT;
+ break;
+ }
+ else {
+ if (!advert.isPlaying()) advert.play();
+ ofEnableAlphaBlending();
+ ofSetColor(255,255,255,((segamt-0.5)*512));
+ }
case GAME_ADVERT:
+ case GAME_ENDINGADVERT:
+ if (gamestate==GAME_ENDINGADVERT)
float aspect=advert.getHeight()/advert.getWidth();
float wOffs=(ofGetHeight()-(ofGetWidth()*aspect))*0.5;
advert.draw(0,wOffs,ofGetWidth(),ofGetWidth()*aspect);
+ ofDisableAlphaBlending(); //may have been turned on during intro
if (advert.getCurrentFrame()==advert.getTotalNumFrames()) {
- gamestate=GAME_READY;
+ gamestate=GAME_ENDINGADVERT;
+ segmentStartTime=ofGetElapsedTimeMillis();
}
break;
}
@@ -276,7 +319,7 @@ void testApp::keyPressed(int key, ofxFenster* win){
void testApp::keyPressed(int key){
switch (key) {
case ' ':
- if (!songs[currentsong]->isPlaying) {
+ if (gamestate==GAME_READY) {
currentlevel=0;
currentsong=nextsong;
songs[currentsong]->setTimeframe(timescale);
@@ -285,6 +328,7 @@ void testApp::keyPressed(int key){
songs[currentsong]->preRoll(5000);
tags[0]->play();
nextsong=(nextsong+1)%songs.size();
+ gamestate=GAME_PRACTICE;
}
break;
case '1':
@@ -312,8 +356,8 @@ void testApp::keyPressed(int key){
break;
case 'w':
if (gamestate==GAME_READY) {
- advert.play();
- gamestate=GAME_ADVERT;
+ segmentStartTime=ofGetElapsedTimeMillis();
+ gamestate=GAME_STARTINGADVERT;
}
break;
case 'f':