summaryrefslogtreecommitdiff
path: root/vfg/src/testApp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'vfg/src/testApp.cpp')
-rwxr-xr-xvfg/src/testApp.cpp104
1 files changed, 53 insertions, 51 deletions
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 0e8d31e..8c701b2 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -178,9 +178,12 @@ void testApp::exit(){
//--------------------------------------------------------------
void testApp::update(){
int ret=game.update();
- if (ret==1000) {
+ if (ret==ASTERISK_GAMESTARTED) {
activatePractice();
}
+ else if (ret==ASTERISK_GAMEOVER) {
+ endGame();
+ }
else if (ret>48&&ret<52) {
songs[currentsong]->playerControl(ret-49);
practiceSong.playerControl(ret-49);
@@ -257,7 +260,7 @@ void testApp::draw(){
float scale=ofGetHeight()/1080.0f;
float bannerscale,aspect,wOffs,seg; //this old chestnut
float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength; //same variable used in all segments
-
+ int hit,missed;
switch(gamestate) {
case GAME_STARTINGINTRO:
case GAME_INTRO:
@@ -352,54 +355,53 @@ void testApp::draw(){
}
else break;
case GAME_READY:
+ ofEnableAlphaBlending();
for (int i=0;i<3;i++) {
//break up standing around movement
if (ofRandom(1.0)<.002) (*playanimal)[i].play("Shuffle");
+ (*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
}
- case GAME_PLAYING:
+ break;
case GAME_PRACTICE:
ofEnableAlphaBlending();
- 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_PRACTICE) {
- int missed=practiceSong.missedNote();
- if (missed>-1) (*playanimal)[missed].playNow("Shudder");
- int hit=practiceSong.hitNote();
- if (hit>-1) (*playanimal)[hit].play("Catch");
-
- }
+ missed=practiceSong.missedNote();
+ if (missed>-1) (*playanimal)[missed].playNow("Shudder");
+ hit=practiceSong.hitNote();
+ if (hit>-1) (*playanimal)[hit].play("Catch");
for (int i=0;i<3;i++) (*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
- if (songs[currentsong]->isPlaying) {
- lyricspanel->draw(ofGetWidth()*0.5,ofGetHeight()*gridY[1],scale);
- songs[currentsong]->draw(hOffs,scale);
- }
- else if (gamestate==GAME_PRACTICE) {
- practiceSong.draw(hOffs,scale);
- }
+ practiceSong.draw(hOffs,scale);
break;
- case GAME_ENDPLAYING:
- //6 seconds to walk in / out -> 12 seconds turnaround
- //frames to start/cycle/stop walking
- //penguin: 11,35,11
- //raccoon: 20,39,43r
- ofEnableAlphaBlending();
- seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001;
- wOffs=hOffs+(0.7*ofGetWidth()*seg);
- for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
- break;
- case GAME_WALKON:
- ofEnableAlphaBlending();
- seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001;
- wOffs=hOffs+(0.7*ofGetWidth()*(1.0f-seg));
- for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
- break;
+ case GAME_PLAYING:
+ ofEnableAlphaBlending();
+ if (showVis) songs[currentsong]->drawNotes(hOffs);
+ missed=songs[currentsong]->missedNote();
+ if (missed>-1) (*playanimal)[missed].playNow("Shudder");
+ hit=songs[currentsong]->hitNote();
+ if (hit>-1) (*playanimal)[hit].play("Catch");
+ for (int i=0;i<3;i++) (*playanimal)[i].draw(hOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
+ lyricspanel->draw(ofGetWidth()*0.5,ofGetHeight()*gridY[1],scale);
+ songs[currentsong]->draw(hOffs,scale);
+ break;
+ case GAME_ENDPLAYING:
+ //6 seconds to walk in / out -> 12 seconds turnaround
+ //frames to start/cycle/stop walking
+ //penguin: 11,35,11
+ //raccoon: 20,39,43r
+ ofEnableAlphaBlending();
+ seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001;
+ wOffs=hOffs+(0.7*ofGetWidth()*seg);
+ for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
+ songs[currentsong]->draw(hOffs,scale);//allows the song to fade its volume out and stop playing
+ break;
+ case GAME_WALKON:
+ ofEnableAlphaBlending();
+ seg=((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001;
+ wOffs=hOffs+(0.7*ofGetWidth()*(1.0f-seg));
+ for (int i=0;i<3;i++) (*playanimal)[i].draw(wOffs+(gridX[i+1]*ofGetHeight()),gridY[0]*ofGetHeight(),scale);
+ break;
}
+
+
//draw tags and logos
switch(gamestate) {
case GAME_STARTINGADVERT:
@@ -494,7 +496,7 @@ void testApp::draw(){
break;
case GAME_PLAYING:
backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0)));
- if (!songs[currentsong]->isPlaying) {
+ if (songs[currentsong]->isGameover()) {
endGame();
}
break;
@@ -562,15 +564,15 @@ void testApp::endGame(){
printf("score: %s\n",score.c_str());
game.endGame(score);
gamestate=GAME_ENDPLAYING;
- tags[6]->play();
- segmentStartTime=ofGetElapsedTimeMillis();
- //6 seconds to walk in / out -> 12 seconds turnaround
- //frames to start/cycle/stop walking
- //penguin: 11,35,11
- //raccoon: 20,39,43
- //penguins: start + 289 = 8.25
- //raccoons: start + 280 = 7.17
- for (int i=0;i<3;i++) {
+ tags[6]->play();
+ segmentStartTime=ofGetElapsedTimeMillis();
+ //6 seconds to walk in / out -> 12 seconds turnaround
+ //frames to start/cycle/stop walking
+ //penguin: 11,35,11
+ //raccoon: 20,39,43
+ //penguins: start + 289 = 8.25
+ //raccoons: start + 280 = 7.17
+ for (int i=0;i<3;i++) {
(*playanimal)[i].play("Walk_start");
for (int j=0;j<9;j++) (*playanimal)[i].play("Walking");
}