summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2012-12-06 11:34:28 +0000
committerComment <tim@gray.(none)>2012-12-06 11:34:28 +0000
commit11322afc79c2d36d5edecd0e6b38186f9f2dd867 (patch)
tree596cc518a40f9625c4049db278b067d450626ed5
parent8fe8572729f186269b02ac2bb149fe9a25671cae (diff)
character transitions
-rwxr-xr-xvfg/bin/data/Levels_DeckTheHalls.4.0.xml2
-rwxr-xr-xvfg/bin/data/Levels_DingDong.2.2.xml2
-rwxr-xr-xvfg/bin/data/Levels_WeWishYou.2.1.xml2
-rw-r--r--vfg/src/Animal.cpp13
-rw-r--r--vfg/src/Animal.h19
-rwxr-xr-xvfg/src/music.cpp11
-rwxr-xr-xvfg/src/music.h21
-rwxr-xr-xvfg/src/testApp.cpp86
-rwxr-xr-xvfg/src/testApp.h15
-rwxr-xr-xvfg/vfg.cbp6
-rw-r--r--vfg/vfg.layout14
11 files changed, 105 insertions, 86 deletions
diff --git a/vfg/bin/data/Levels_DeckTheHalls.4.0.xml b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml
index 5228895..9243097 100755
--- a/vfg/bin/data/Levels_DeckTheHalls.4.0.xml
+++ b/vfg/bin/data/Levels_DeckTheHalls.4.0.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<VFxmas timebase="1000" length="98840">
+<VFxmas timebase="1000" length="98840" name="Deck the Halls with Boughs of Holly">
<Level Time="0" Lives="0"/>
<Level Time="37920" Lives="5"/>
<Level Time="69400" Lives="4"/>
diff --git a/vfg/bin/data/Levels_DingDong.2.2.xml b/vfg/bin/data/Levels_DingDong.2.2.xml
index 0636305..1bbc101 100755
--- a/vfg/bin/data/Levels_DingDong.2.2.xml
+++ b/vfg/bin/data/Levels_DingDong.2.2.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<VFxmas timebase="25" length="2320">
+<VFxmas timebase="25" length="2320" name="Ding Dong Merrily on High">
<Level Time="0" Lives="0"/>
<Level Time="807" Lives="5"/>
<Level Time="1465" Lives="4"/>
diff --git a/vfg/bin/data/Levels_WeWishYou.2.1.xml b/vfg/bin/data/Levels_WeWishYou.2.1.xml
index 8f037af..97c7d66 100755
--- a/vfg/bin/data/Levels_WeWishYou.2.1.xml
+++ b/vfg/bin/data/Levels_WeWishYou.2.1.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<VFxmas timebase="25" length="2549">
+<VFxmas timebase="25" length="2549" name="We wish you a Merry Christmas">
<Level Time="0" Lives="0"/>
<Level Time="870" Lives="5"/>
<Level Time="1221" Lives="4"/>
diff --git a/vfg/src/Animal.cpp b/vfg/src/Animal.cpp
deleted file mode 100644
index 815aa81..0000000
--- a/vfg/src/Animal.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "Animal.h"
-
-Animal::Animal()
-{
- //ctor
-}
-
-Animal::~Animal()
-{
- //dtor
-}
-void Animal::update(){
-}
diff --git a/vfg/src/Animal.h b/vfg/src/Animal.h
deleted file mode 100644
index 4155901..0000000
--- a/vfg/src/Animal.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef ANIMAL_H
-#define ANIMAL_H
-
-#include "ofMain.h"
-#include "ofxXmlSettings.h"
-#include "Puppet.h"
-
-
-class Animal: public Puppet
-{
- public:
- Animal();
- virtual ~Animal();
- void update();
- protected:
- private:
-};
-
-#endif // ANIMAL_H
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp
index e715892..a2e7020 100755
--- a/vfg/src/music.cpp
+++ b/vfg/src/music.cpp
@@ -307,7 +307,16 @@ void song::drawNotes(float hOffs){
}
string song::getScoreString(){
int songTime=ofGetElapsedTimeMillis()-startTime;
- return ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime));
+ return ofToString((float)songTime/1000.0f,1)+": level "+ofToString(levels.getLevel(songTime))+": lives "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime));
+}
+string song::getName(){
+ return levels.name;
+}
+int song::getLength(){
+ return levels.length;
+}
+bool song::isFinished(){
+ return (getCurrentTime()>=getLength());
}
void song::draw(float hOffs,float scale){
int songTime=ofGetElapsedTimeMillis()-startTime;
diff --git a/vfg/src/music.h b/vfg/src/music.h
index e4e8601..1aa956a 100755
--- a/vfg/src/music.h
+++ b/vfg/src/music.h
@@ -17,7 +17,8 @@ class levelscore {
if( !XML.loadFile(filename) ){
printf("unable to load %s check data/ folder\n",filename.c_str());
}else{
- int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0);
+ int multiplier=1000/XML.getAttribute("VFxmas", "timebase",1000,0);
+ name=XML.getAttribute("VFxmas", "name","",0);
length=XML.getAttribute("VFxmas", "length",0,0)*multiplier;
if(XML.pushTag("VFxmas")) {
for (int i=0;i<XML.getNumTags("Level");i++) {
@@ -74,10 +75,11 @@ class levelscore {
}
return 2<<20; // a big number
}
- int length;
+ int length;
+ string name;
private:
map<int,int> levels;
-
+
};
//---------------------------------------------------------------------------------------------------------------------------------------------
class note {
@@ -181,7 +183,7 @@ class musicscore: public score {
map<int,flake*>::iterator missedFlake;
int timeframe;
float nowpoint;
-
+
vector<Puppet> snowflakes;
};
@@ -205,16 +207,19 @@ class song {
void playerControl(int key);
int getLevel(long time);
int getCurrentTime();
- string getScoreString();
-
+ string getScoreString();
+ string getName();
+ int getLength();
+ bool isFinished();
+
musicscore notes;
private:
ofSoundPlayer backing;
ofSoundPlayer melody;
lyricscore lyrics;
-
+
levelscore levels;
- long startTime;
+ int startTime;
bool isPreroll,isPractice;
int fThreshStart,fThreshEnd;
diff --git a/vfg/src/testApp.cpp b/vfg/src/testApp.cpp
index 986673c..0e8d31e 100755
--- a/vfg/src/testApp.cpp
+++ b/vfg/src/testApp.cpp
@@ -46,14 +46,14 @@ void testApp::setup(){
//printf("we wish you a merry xmas:\n");
//songs[0]->notes.printNotes();
- for (int i=0;i<3;i++) penguins.push_back(Animal());
+ for (int i=0;i<3;i++) penguins.push_back(Puppet());
penguins[0].load("Penguin-Blue.xml");
penguins[1].load("Penguin-Purple.xml");
penguins[2].load("Penguin-Green.xml");
// temp save time
- for (int i=0;i<3;i++) raccoons.push_back(Animal());
+ for (int i=0;i<3;i++) raccoons.push_back(Puppet());
raccoons[0].load("Raccoon-Blue.xml");
raccoons[1].load("Raccoon-Purple.xml");
raccoons[2].load("Raccoon-Green.xml");
@@ -138,7 +138,9 @@ void testApp::setup(){
gui.add(ts.setup("timescale",timescale,0,10000,255));
keyThresh=1500;
gui.add(kT.setup("keythresh",keyThresh,0,4000,255));
- gui.add(showWire.setup("birdwire",true));
+ birdpoint=0.6;
+ gui.add(bP.setup("wire level",birdpoint,0.5,0.7,255));
+ gui.add(showWire.setup("wire",true));
ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, 200, 400, OF_WINDOW);
win->setWindowTitle("config");
@@ -152,7 +154,7 @@ void testApp::setup(){
void testApp::loadanimals(string which) {
playanimals.clear();
- for (int i=0;i<3;i++) playanimals.push_back(Animal());
+ for (int i=0;i<3;i++) playanimals.push_back(Puppet());
if (which=="Penguins") {
playanimals[0].load("Penguin-Blue.xml");
@@ -200,9 +202,6 @@ void testApp::update(){
currentlevel++;
printf("finished level %i!\n",currentlevel);
}
- for (int i=0;i<3;i++) {
- (*playanimal)[i].update();
- }
switch(gamestate) {
case GAME_READY:
case GAME_STARTPLAYING:
@@ -256,7 +255,7 @@ void testApp::draw(){
ofSetColor(255,255,255);
float hOffs=(ofGetWidth()-ofGetHeight())/2;
float scale=ofGetHeight()/1080.0f;
- float bannerscale,aspect,wOffs; //this old chestnut
+ float bannerscale,aspect,wOffs,seg; //this old chestnut
float segamt=((float)(ofGetElapsedTimeMillis()-segmentStartTime)*2.0f)/fadelength; //same variable used in all segments
switch(gamestate) {
@@ -271,6 +270,7 @@ void testApp::draw(){
case GAME_PRACTICE:
case GAME_PLAYING:
case GAME_ENDPLAYING:
+ case GAME_WALKON:
break;
}
//draw backgrounds
@@ -288,6 +288,7 @@ void testApp::draw(){
case GAME_PRACTICE:
case GAME_PLAYING:
case GAME_ENDPLAYING:
+ case GAME_WALKON:
drawBackgroundLayers();
break;
case GAME_STARTINGADVERT:
@@ -357,7 +358,6 @@ void testApp::draw(){
}
case GAME_PLAYING:
case GAME_PRACTICE:
- case GAME_ENDPLAYING:
ofEnableAlphaBlending();
if (songs[currentsong]->isPlaying) {
ofSetColor(255,255,255);
@@ -382,8 +382,25 @@ void testApp::draw(){
else if (gamestate==GAME_PRACTICE) {
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;
}
- //draw characters
+ //draw tags and logos
switch(gamestate) {
case GAME_STARTINGADVERT:
if (segamt<0.5) {
@@ -398,12 +415,11 @@ void testApp::draw(){
}
else break;
case GAME_READY:
- //DCC LOGO
- logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
case GAME_STARTPLAYING:
case GAME_PRACTICE:
case GAME_PLAYING:
case GAME_ENDPLAYING:
+ case GAME_WALKON:
ofEnableAlphaBlending();
if (gamestate!=GAME_STARTINGADVERT&&gamestate!=GAME_ENDINGADVERT) ofSetColor(255,255,255);
for (int i=0;i<tags.size();i++) {
@@ -419,7 +435,7 @@ void testApp::draw(){
case GAME_PRACTICE:
ofEnableAlphaBlending();
bannerscale=scale*(1.0f-(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.002,1.0))*0.325));
- wirebirds.draw(ofGetWidth()/2,ofGetHeight()*0.6,scale);
+ wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale);
segamt=1.0;
ofEnableAlphaBlending();
banner.draw(ofGetWidth()*0.5,0,bannerscale);
@@ -442,12 +458,15 @@ void testApp::draw(){
break;
case GAME_STARTPLAYING:
case GAME_PLAYING:
- if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*0.6,scale);
+ if (showWire) wirebirds.draw(ofGetWidth()/2,ofGetHeight()*birdpoint,scale);
bannerscale=scale*0.675;
ofEnableAlphaBlending();
banner.draw(ofGetWidth()*0.5,0,bannerscale);
break;
case GAME_ENDPLAYING:
+ case GAME_WALKON:
+ //DCC LOGO
+ logos[1]->draw((gridX[0]*ofGetHeight())+hOffs,gridY[1]*ofGetHeight(),scale);
bannerscale=scale*(0.675+(max(0.0,min(((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001,1.0))*0.325));
ofEnableAlphaBlending();
banner.draw(ofGetWidth()*0.5,0,bannerscale);
@@ -476,19 +495,22 @@ void testApp::draw(){
case GAME_PLAYING:
backgroundmusic.setVolume(max(0.0,1.0-(segamt*2.0)));
if (!songs[currentsong]->isPlaying) {
- game.endGame("GOOD!");
- gamestate=GAME_ENDPLAYING;
- tags[6]->play();
- segmentStartTime=ofGetElapsedTimeMillis();
+ endGame();
}
break;
case GAME_ENDPLAYING:
backgroundmusic.setVolume(max(0.0,(segamt-0.5)*2.0));
- if (segamt>1.0) {
- gamestate=GAME_READY;
+ if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
+ gamestate=GAME_WALKON;
switchAnimals();
}
break;
+ case GAME_WALKON:
+ if (((float)(ofGetElapsedTimeMillis()-segmentStartTime))*.001>6.0) {
+ gamestate=GAME_READY;
+ segmentStartTime=ofGetElapsedTimeMillis();
+ }
+ break;
}
}
@@ -534,6 +556,25 @@ void testApp::switchAnimals(){
if (playanimal==&raccoons) playanimal=&penguins;
else playanimal =&raccoons;
}
+void testApp::endGame(){
+ string score=songs[currentsong]->getName()+":"+ofToString(((float)songs[currentsong]->getCurrentTime())*.001)+(songs[currentsong]->isFinished()?":finished":":level "+ofToString(currentlevel));
+ //printf("current time:%i length:%i \n",songs[currentsong]->getCurrentTime(),songs[currentsong]->getLength())
+ 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++) {
+ (*playanimal)[i].play("Walk_start");
+ for (int j=0;j<9;j++) (*playanimal)[i].play("Walking");
+ }
+}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
switch (key) {
@@ -560,9 +601,8 @@ void testApp::keyPressed(int key){
}
break;
case 'e':
- if (gamestate==GAME_PLAYING) {
- game.endGame("GOOD!");
- gamestate=GAME_READY;
+ if (gamestate==GAME_PLAYING||gamestate==GAME_PRACTICE) {
+ endGame();
}
break;
case 'q':
diff --git a/vfg/src/testApp.h b/vfg/src/testApp.h
index d4a9627..0cc0942 100755
--- a/vfg/src/testApp.h
+++ b/vfg/src/testApp.h
@@ -8,7 +8,6 @@
#include "music.h"
#include "Asterisk.h"
#include "Puppet.h"
-#include "Animal.h"
#include "Tag.h";
/*
@@ -48,6 +47,7 @@ ramdisk for movies
#define GAME_PRACTICE 9
#define GAME_PLAYING 10
#define GAME_ENDPLAYING 11
+#define GAME_WALKON 12
class guiWindow;
@@ -76,6 +76,7 @@ class testApp : public ofxFensterListener{
void activateGame();
void activatePractice();
void switchAnimals();
+ void endGame();
ofVideoPlayer intro;
ofVideoPlayer advert;
@@ -88,14 +89,14 @@ class testApp : public ofxFensterListener{
song practiceSong;
- vector<Animal> penguins;
- vector<Animal> raccoons;
+ vector<Puppet> penguins;
+ vector<Puppet> raccoons;
- //vector<vector<Animal> > animals;
+ //vector<vector<Puppet> > animals;
- //vector<Animal> playanimals;
+ //vector<Puppet> playanimals;
- vector<Animal>* playanimal;
+ vector<Puppet>* playanimal;
vector<Tag*> tags;
vector<Billboard*> logos;
@@ -128,6 +129,8 @@ class testApp : public ofxFensterListener{
ofxParameter<int> timescale;
ofxIntSlider kT;
ofxParameter<int> keyThresh;
+ ofxFloatSlider bP;
+ ofxParameter<float> birdpoint;
ofxToggle showWire;
};
diff --git a/vfg/vfg.cbp b/vfg/vfg.cbp
index cc07b3b..408e357 100755
--- a/vfg/vfg.cbp
+++ b/vfg/vfg.cbp
@@ -33,12 +33,6 @@
<Unit filename="config.make">
<Option virtualFolder="build config" />
</Unit>
- <Unit filename="src/Animal.cpp">
- <Option virtualFolder="src/" />
- </Unit>
- <Unit filename="src/Animal.h">
- <Option virtualFolder="src/" />
- </Unit>
<Unit filename="src/Asterisk.cpp">
<Option virtualFolder="src/" />
</Unit>
diff --git a/vfg/vfg.layout b/vfg/vfg.layout
index e3ee66d..06595b0 100644
--- a/vfg/vfg.layout
+++ b/vfg/vfg.layout
@@ -5,7 +5,7 @@
<Cursor position="80" topLine="0" />
</File>
<File name="src/Asterisk.cpp" open="1" top="0" tabpos="5">
- <Cursor position="487" topLine="27" />
+ <Cursor position="484" topLine="21" />
</File>
<File name="src/Asterisk.h" open="0" top="0" tabpos="3">
<Cursor position="106" topLine="23" />
@@ -13,8 +13,8 @@
<File name="src/Puppet.cpp" open="1" top="0" tabpos="1">
<Cursor position="502" topLine="0" />
</File>
- <File name="src/Puppet.h" open="0" top="0" tabpos="2">
- <Cursor position="312" topLine="0" />
+ <File name="src/Puppet.h" open="1" top="0" tabpos="6">
+ <Cursor position="312" topLine="7" />
</File>
<File name="src/Tag.h" open="0" top="0" tabpos="5">
<Cursor position="551" topLine="0" />
@@ -25,13 +25,13 @@
<File name="src/music.cpp" open="0" top="0" tabpos="5">
<Cursor position="10158" topLine="241" />
</File>
- <File name="src/music.h" open="0" top="0" tabpos="6">
- <Cursor position="4738" topLine="125" />
+ <File name="src/music.h" open="1" top="0" tabpos="8">
+ <Cursor position="4738" topLine="0" />
</File>
<File name="src/testApp.cpp" open="1" top="1" tabpos="4">
- <Cursor position="16084" topLine="505" />
+ <Cursor position="15897" topLine="484" />
</File>
<File name="src/testApp.h" open="1" top="0" tabpos="3">
- <Cursor position="2007" topLine="46" />
+ <Cursor position="1353" topLine="23" />
</File>
</CodeBlocks_layout_file>