summaryrefslogtreecommitdiff
path: root/vfg/src
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-12-03 17:04:02 +0000
committerTim Redfern <tim@eclectronics.org>2012-12-03 17:04:02 +0000
commitf7bee21ada14851da8626a3784821ded25333fe6 (patch)
tree19043f79373b3f4493c5e262512e8c6768adc8c1 /vfg/src
parent193cadbc158c5423691b91bae497e44cbef436e9 (diff)
working on train
Diffstat (limited to 'vfg/src')
-rwxr-xr-xvfg/src/testApp.cpp76
-rwxr-xr-xvfg/src/testApp.h46
2 files changed, 78 insertions, 44 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':
diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h
index 4890724..c287fb1 100755
--- a/vfg/src/testApp.h
+++ b/vfg/src/testApp.h
@@ -30,36 +30,24 @@ Maximilian is an audio synthesis and signal processing library written in C++. I
- realtime music information retrieval functions: spectrum analysis, spectral features, octave analysis, and MFCCs
- example projects for Windows and MacOS, using command line and OpenFrameworks environments
-
-
-game design demo
-
-state - game started, game over
-
-while playing - game full volume - if you miss a flake - starts countdown - game gets quieter and stars get fainter - when countdown is down 'game over'
-
-keys - volume - control drawing of stars - game state
-
-
-changes 05112012
-
-event suppression working?
-overlap
-
-
-character class- load sprites from xml- play behaviours- block animations when others are playing
-
-//hooking up the backend
-1 - start game - sends message - starts if acknowledged
-2 - receive dtmf
-3 - hang up
+transitions
+break clap movements
+practice mode
+ramdisk for movies
*/
-#define GAME_INTRO 1
-#define GAME_READY 2
-#define GAME_ADVERT 3
-#define GAME_PLAYING 4
+#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
class guiWindow;
@@ -83,6 +71,8 @@ class testApp : public ofxFensterListener{
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
+
+ void drawBackgroundLayers();
ofVideoPlayer intro;
ofVideoPlayer advert;
@@ -118,7 +108,7 @@ class testApp : public ofxFensterListener{
bool showVis;
bool fullscreenoutput;
- int currentsong,nextsong,gamestate;
+ int currentsong,nextsong,gamestate,segmentStartTime,fadelength;
guiWindow *guiWin;
ofxPanel gui;