summaryrefslogtreecommitdiff
path: root/vfg/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2012-12-14 12:53:44 +0000
committerComment <tim@gray.(none)>2012-12-14 12:53:44 +0000
commit066b911b19d93191fd5a89b8cd14c51aa18e2fd9 (patch)
tree00ef1860b1e51bdca774444a3e959b66dca43809 /vfg/src
parent19c84c74efd5b8ffd1fb8184037910c831990d2e (diff)
ready for Dublin
Diffstat (limited to 'vfg/src')
-rwxr-xr-xvfg/src/Asterisk.cpp7
-rwxr-xr-xvfg/src/music.cpp5
-rwxr-xr-xvfg/src/music.h14
-rwxr-xr-xvfg/src/testApp.cpp49
-rwxr-xr-xvfg/src/testApp.h3
5 files changed, 49 insertions, 29 deletions
diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp
index 1152efa..f1b8058 100755
--- a/vfg/src/Asterisk.cpp
+++ b/vfg/src/Asterisk.cpp
@@ -17,7 +17,8 @@ std::vector<std::string> &split(const std::string &s, char delim, std::vector<st
Asterisk::~Asterisk()
{
stopThread();
- pclose(file);
+ pclose(file);
+ printf("asterisk closed\n");
}
/*
@@ -56,7 +57,7 @@ void Asterisk::threadedFunction(){
else {
printf("status err: %s\n",buf);
}
-
+
//unlock();
//}
@@ -108,7 +109,7 @@ void Asterisk::scmd(string s) {
filenum=fileno(file);
fcntl(filenum, F_SETFL, O_NONBLOCK);
//printf("close file\n");
- pclose(file); //is blocking!
+ pclose(file); //is blocking!
}
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index 68dca7f..a3ebfc5 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -288,7 +288,7 @@ void song::stop() {
backing.stop();
melody.stop();
isPlaying=false;
- printf("stoppping song: %i (%i)\n",ofGetElapsedTimeMillis()-startTime,levels.length);
+ printf("stopping song: %i (%i)\n",ofGetElapsedTimeMillis()-startTime,levels.length);
}
void song::preRoll(long preroll) {
startTime=ofGetElapsedTimeMillis()+preroll;
@@ -330,6 +330,9 @@ void song::gameOver(){
}
bool song::isFinished(){
return (ofGetElapsedTimeMillis()-startTime>=levels.length);
+}
+void song::resize(){
+ lyrics.loadFont();
}
void song::draw(float hOffs,float scale){
int songTime=ofGetElapsedTimeMillis()-startTime;
diff --git a/vfg/src/music.h b/vfg/src/music.h
index c4a26ca..8792d6a 100755
--- a/vfg/src/music.h
+++ b/vfg/src/music.h
@@ -131,10 +131,8 @@ class lyricscore: public score {
//draws lyrics to screen for a certain time
public:
lyricscore() {
- font.loadFont("VodafoneRg_Bd.ttf", 31*(ofGetHeight()/1080.0f), true, true); //hard coded scaling
- font.setLineHeight(34.0f);
- font.setLetterSpacing(1.035);
- fadeout=500; //ms
+ fadeout=500; //ms
+ loadFont();
}
void load(string filename) {
if( !XML.loadFile(filename) ){
@@ -151,6 +149,11 @@ class lyricscore: public score {
}
}
+ void loadFont() {
+ font.loadFont("VodafoneRg_Bd.ttf", 31*(ofGetHeight()/1080.0f), true, true); //hard coded scaling
+ font.setLineHeight(34.0f);
+ font.setLetterSpacing(1.035);
+ }
void draw(float hOffs);
private:
map<int,lyric*> lyrics;
@@ -213,7 +216,8 @@ class song {
bool isGameover();
void gameOver();
bool isFinished();
- bool gameover;
+ bool gameover;
+ void resize();
musicscore notes;
private:
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 2a95571..cd7572c 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -122,7 +122,7 @@ void testApp::setup(){
advert.setLoopState(OF_LOOP_NONE);
advert.setVolume(1.0);
- background.loadMovie("RAM/Background_v3.mp4");
+ background.loadMovie("RAM/Background_v4.mp4");
background.setLoopState(OF_LOOP_NORMAL);
background.play();
@@ -193,6 +193,11 @@ void testApp::exit(){
//--------------------------------------------------------------
void testApp::update(){
+ if (ofGetHeight()!=gameHeight) {
+ //game has been resized
+ for (int i=0;i<songs.size();i++) songs[i]->resize();
+ gameHeight=ofGetHeight();
+ }
int ret=game.update();
if (ret==ASTERISK_GAMESTARTED) {
activatePractice();
@@ -203,20 +208,25 @@ void testApp::update(){
endGame();
}
}
- else if (ret>48&&ret<52) {
- songs[currentsong]->playerControl(ret-49);
- practiceSong.playerControl(ret-49);
- (*playanimal)[ret-49].playNow("Clap");
- }
- else if (ret>51&&ret<55) {
- songs[currentsong]->playerControl(ret-52);
- practiceSong.playerControl(ret-52);
- (*playanimal)[ret-52].playNow("Clap");
- }
- else if (ret>54&&ret<58) {
- songs[currentsong]->playerControl(ret-55);
- practiceSong.playerControl(ret-55);
- (*playanimal)[ret-55].playNow("Clap");
+ if (ret>48&&58) {
+ if (gamestate==GAME_READY) gamestate=GAME_PRACTICE; //caught missed game acknowledgement!
+ if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE||gamestate==GAME_PRACTICE2) {
+ if (ret>48&&ret<52) {
+ songs[currentsong]->playerControl(ret-49);
+ practiceSong.playerControl(ret-49);
+ (*playanimal)[ret-49].playNow("Clap");
+ }
+ else if (ret>51&&ret<55) {
+ songs[currentsong]->playerControl(ret-52);
+ practiceSong.playerControl(ret-52);
+ (*playanimal)[ret-52].playNow("Clap");
+ }
+ else if (ret>54&&ret<58) {
+ songs[currentsong]->playerControl(ret-55);
+ practiceSong.playerControl(ret-55);
+ (*playanimal)[ret-55].playNow("Clap");
+ }
+ }
}
if (songs[currentsong]->isPlaying&&songs[currentsong]->getLevel(ofGetElapsedTimeMillis()+4000)>currentlevel) {
int anim=ofRandom(1.9999); //this gives a binary random number
@@ -358,7 +368,7 @@ void testApp::draw(){
}
}
aspect=advert.getHeight()/advert.getWidth();
- float maxwidth=min((float)ofGetWidth(),ofGetHeight()*1.2f);
+ float maxwidth=ofGetWidth(); //min((float)ofGetWidth(),ofGetHeight()*1.2f);
float wstart=(ofGetWidth()-maxwidth)*0.5;
wOffs=(ofGetHeight()-(maxwidth*aspect))*0.5;
advert.draw(wstart,wOffs,maxwidth,maxwidth*aspect);
@@ -457,7 +467,7 @@ void testApp::draw(){
else break;
case GAME_ENDTITLE:
//DCC LOGO FOR DUBLIN
- //logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
+ logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
case GAME_ENDINGINTRO:
case GAME_READY:
case GAME_STARTPLAYING:
@@ -473,7 +483,7 @@ void testApp::draw(){
}
logos[0]->draw((gridX[0]*ofGetHeight())+hOffs,0,scale);
break;
-
+
}
//draw banner and wirebirds
bannerscale=scale;
@@ -529,7 +539,8 @@ void testApp::draw(){
case GAME_WALKON:
case GAME_ENDINGINTRO:
case GAME_INTRO:
- case GAME_ENDTITLE:
+ case GAME_PRACTICE:
+ case GAME_ENDTITLE:
if (ofGetWidth()>ofGetHeight()) {
float slice=(ofGetWidth()-ofGetHeight())/2;
ofSetColor(0,0,0);
diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h
index 14a0fbf..a405972 100755
--- a/vfg/src/testApp.h
+++ b/vfg/src/testApp.h
@@ -82,7 +82,7 @@ class testApp : public ofxFensterListener{
void switchAnimals();
void endGame();
void hangUp();
-
+
void queueWalkOff();
void queueWalkOn();
@@ -122,6 +122,7 @@ class testApp : public ofxFensterListener{
bool showFPS;
bool showVis;
bool fullscreenoutput;
+ int gameHeight;
int currentsong,nextsong,gamestate,segmentStartTime;