summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xvfg/src/Asterisk.cpp30
-rwxr-xr-xvfg/src/Asterisk.h11
-rwxr-xr-xvfg/src/Puppet.h5
-rwxr-xr-xvfg/src/music.cpp17
-rwxr-xr-xvfg/src/music.h2
-rwxr-xr-xvfg/src/testApp.cpp104
-rwxr-xr-xvfg/src/testApp.h5
-rw-r--r--vpn/digiweb_vpn/server.conf1
8 files changed, 98 insertions, 77 deletions
diff --git a/vfg/src/Asterisk.cpp b/vfg/src/Asterisk.cpp
index b78678e..98ffd9d 100755
--- a/vfg/src/Asterisk.cpp
+++ b/vfg/src/Asterisk.cpp
@@ -62,27 +62,25 @@ void Asterisk::setup(string passcode,int millis){
udpConnection.Bind(5000);
udpConnection.SetNonBlocking(true);
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode "+passcode+"\"'");
- state=WAITING; //for acknowledge
- isPlaying=false;
+ state=ASTERISK_WAITING; //for acknowledge
statusPollMillis=millis;
if (statusPollMillis>0) startThread(true, false); // blocking, verbose
}
void Asterisk::startGame(){
- if (!isPlaying&&queued) {
+ if (state==ASTERISK_IDLE&&queued) {
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"devstate change Custom:GAME NOT_INUSE\"'");
printf("Asterisk: attempting to dequeue\n");
- state=WAITING;
+ state=ASTERISK_WAITING;
}
}
void Asterisk::endGame(string score){
printf("Asterisk: request hangup %s\n",playerCode.c_str());
- if (isPlaying) {
+ if (state==ASTERISK_PLAYING) {
cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME statuscode "+score+"\"'");
string emsg="ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"hangup request "+playerCode+"\"'";
cmd(emsg);
printf("Asterisk: hanging up %s\n",playerCode.c_str());
- state=WAITING;
- isPlaying=false;
+ state=ASTERISK_IDLE;
}
}
void Asterisk::cmd(string s) {
@@ -95,7 +93,7 @@ void Asterisk::cmd(string s) {
int Asterisk::update(){
//capture stdin response from popen
- if (state==WAITING||state==STARTING) {
+ if (state==ASTERISK_WAITING||state==ASTERISK_STARTING) {
char buf[100];
ssize_t r = read(filenum, buf, 1000);
//if (r == -1 && errno == EAGAIN)
@@ -104,13 +102,12 @@ int Asterisk::update(){
if (r > 0) {
pclose(file);
string msg=string(buf);
- state=IDLE;
+ state=ASTERISK_IDLE;
//received data is always a command ACKNOWLEDGEMENT
//can never issue a new one until last one returns?
if (msg.compare(0,8,"Changing")==0) {
printf("player dequeued\n");
- state==PLAYING;
- isPlaying=true;
+ state=ASTERISK_STARTING;
}
else {
printf("stdin says: %s\n",buf);
@@ -127,15 +124,20 @@ int Asterisk::update(){
//printf("Asterisk: %s\n",msg.c_str());
if (msg.length()>3) {
//printf("status msg: %s\n",msg.c_str());
- if (msg.substr(0,5)=="Local") {
- state=PLAYING;
+ if (msg.substr(0,6)=="Hangup") {
+ state=ASTERISK_IDLE;
+ return ASTERISK_GAMEOVER;
+ }
+ if (msg.substr(0,5)=="Local"&&state==ASTERISK_STARTING) {
+ state=ASTERISK_PLAYING;
playerCode=msg.substr(0,msg.length()-1);
printf("Asterisk: game started: code %s\n",playerCode.c_str());
- return 1000;
+ return ASTERISK_GAMESTARTED;
}
return 0;
}
else {
+ //message length of <3 is a key
return ofToInt(msg);
}
}
diff --git a/vfg/src/Asterisk.h b/vfg/src/Asterisk.h
index 5033a5c..8093213 100755
--- a/vfg/src/Asterisk.h
+++ b/vfg/src/Asterisk.h
@@ -4,10 +4,12 @@
#include "ofMain.h"
#include "ofxNetwork.h"
-#define IDLE 0
-#define WAITING 1
-#define STARTING 2
-#define PLAYING 3
+#define ASTERISK_IDLE 0
+#define ASTERISK_WAITING 1
+#define ASTERISK_STARTING 2
+#define ASTERISK_PLAYING 3
+#define ASTERISK_GAMESTARTED 1000
+#define ASTERISK_GAMEOVER 1001
class Asterisk: public ofThread
@@ -31,7 +33,6 @@ class Asterisk: public ofThread
void endGame(string score);
int update();
int state;
- bool isPlaying;
int queued;
protected:
diff --git a/vfg/src/Puppet.h b/vfg/src/Puppet.h
index 4bebb45..1f6d90a 100755
--- a/vfg/src/Puppet.h
+++ b/vfg/src/Puppet.h
@@ -8,7 +8,10 @@
/*
"base" clip will be drawn unless another clip is playing
-TODO: make resolution independent
+hoe to create synced anim at time
+1) dead reckoning from outside
+2) special clip@time method
+3) change to timed clips (option?)
*/
class puppetSprite: public ofxSprite {
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index a2e7020..c920a02 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -301,6 +301,7 @@ void song::preRoll(long preroll) {
notes.start(startTime);
isPreroll=true;
isPlaying=true;
+ gameover=false;
}
void song::drawNotes(float hOffs){
notes.drawNotes(hOffs,&levels);
@@ -315,8 +316,11 @@ string song::getName(){
int song::getLength(){
return levels.length;
}
-bool song::isFinished(){
- return (getCurrentTime()>=getLength());
+bool song::isGameover(){
+ return gameover;
+}
+bool song::isFinished(){
+ return (ofGetElapsedTimeMillis()-startTime>=levels.length);
}
void song::draw(float hOffs,float scale){
int songTime=ofGetElapsedTimeMillis()-startTime;
@@ -334,7 +338,8 @@ void song::draw(float hOffs,float scale){
if (levels.getLives(songTime)) {
if (notes.missedFlakes>levels.getLives(songTime)) {
//work out score
- stop();
+ //stop();
+ gameover=true;
}
}
}
@@ -342,9 +347,13 @@ void song::draw(float hOffs,float scale){
if (!isPractice) lyrics.draw(hOffs);
if (songTime>levels.length) {
printf("stopping: %i (%i)\n",songTime,levels.length);
- stop();
+ //stop();
+ gameover=true;
}
}
+ else {
+ //fade out song + melody :: clean up
+ }
}
void song::playerControl(int key){
notes.playerControl(key);
diff --git a/vfg/src/music.h b/vfg/src/music.h
index 1aa956a..60a35f2 100755
--- a/vfg/src/music.h
+++ b/vfg/src/music.h
@@ -210,7 +210,9 @@ class song {
string getScoreString();
string getName();
int getLength();
+ bool isGameover();
bool isFinished();
+ bool gameover;
musicscore notes;
private:
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");
}
diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h
index 0cc0942..4b369bf 100755
--- a/vfg/src/testApp.h
+++ b/vfg/src/testApp.h
@@ -144,7 +144,7 @@ public:
void draw();
void dragEvent(ofDragInfo dragInfo,ofxFenster* win);
void windowMoved(int x, int y);
- string levelnames[11]={
+ string levelnames[12]={
"STARTINGINTRO",
"INTRO",
"ENDINGINTRO",
@@ -155,7 +155,8 @@ public:
"STARTPLAYING",
"PRACTICE",
"PLAYING",
- "ENDPLAYING"
+ "ENDPLAYING",
+ "WALKON"
};
};
diff --git a/vpn/digiweb_vpn/server.conf b/vpn/digiweb_vpn/server.conf
index f84f4f4..5c3963f 100644
--- a/vpn/digiweb_vpn/server.conf
+++ b/vpn/digiweb_vpn/server.conf
@@ -6,3 +6,4 @@ keepalive 10 60
ping-timer-rem
persist-tun
persist-key
+