summaryrefslogtreecommitdiff
path: root/gaunt01/src/bird.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gaunt01/src/bird.cpp')
-rw-r--r--gaunt01/src/bird.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/gaunt01/src/bird.cpp b/gaunt01/src/bird.cpp
index 0a17563..e27a2a2 100644
--- a/gaunt01/src/bird.cpp
+++ b/gaunt01/src/bird.cpp
@@ -16,20 +16,20 @@ bird::bird()
if (model.loadSeqs("Bird-anim.xml")) printf("animation loaded with %i sequences\n",model.getNumSequences());
else printf("animation XML file not parsed\n");
-
+
model.sequences["flap"].start();
currentseq="hover";
-
+
texture.loadImage("TextureBird.jpg");
//starting pos
- position=ofVec3f(ofGetWidth()/2,ofGetHeight(),-100); //ofGetHeight()/4);
- heading=ofVec3f(-1,0,0);
- direction=ofVec3f(-1,0,0);
+ position=ofVec3f(ofGetWidth()/2,ofGetHeight(),-ofGetHeight()/4);
+ heading=-90;
+ direction=ofVec3f(0,-1,0); //director for a heading of 0, level
velocity=ofGetWidth()/50;
- turnAngle=-1;
- diveAngle=0;
+ turnRate=20;
+ diveRate=0;
lastTime=ofGetElapsedTimef();
}
@@ -43,20 +43,35 @@ void bird::update(const vector<ofVec3f>& players){
float time=ofGetElapsedTimef();
float timeSeg=time-lastTime;
lastTime=time;
- position+=direction*velocity*timeSeg;
+ heading+=turnRate*timeSeg;
+
+ position-=direction.rotated(heading,ofVec3f(0,0,-1))*velocity*timeSeg; //.rotate(heading,ofVec3f(0,1,0))
}
void bird::draw(){
glEnable(GL_DEPTH_TEST);
ofPushMatrix();
ofTranslate(position);
- //ofRotate(direction);
ofRotate(90,0,0,1);
ofRotate(90,-1,0,0);
+ ofRotate(heading+90,0,1,0);
+ ofSetHexColor(0xffffff);
ofScale(.15,.15,.15);
bindTexture(texture);
- model.drawAnimated();
+ model.drawAnimated();
unbindTexture(texture);
ofPopMatrix();
glDisable(GL_DEPTH_TEST);
}
+void bird::drawShadow(){
+ ofPushMatrix();
+ ofTranslate(position);
+ ofRotate(90,0,0,1);
+ ofRotate(90,-1,0,0);
+ ofRotate(heading+90,0,1,0);
+ ofSetHexColor(0x000000);
+ ofTranslate(0,(-ofGetHeight()/4)+5,0);
+ ofScale(.15,0,.15);
+ model.drawAnimated();
+ ofPopMatrix();
+}